读取文件内容

#include<stdio.h>
 int main(void){
  FILE *fp;//定义指针
  char ch;
  if((fp=fopen("d:\\yy.txt","r"))==NULL){//
      printf("cannot open file,press any key to exit!");
      exit(0);
  }
  while((ch=fgetc(fp))!=EOF){
    fputc(ch,stdout);
  }
  fclose(fp);
}

 

posted @ 2018-04-27 22:20  sunnybowen  阅读(117)  评论(0编辑  收藏  举报