1 //feof函数的作用是判断文件指针是否在文件末尾,如果在文件末尾,返回非0,否则返回0 2 //feof(文件指针) 3 #include<stdio.h> 4 #include<stdlib.h> 5 int main(){ 6 FILE *fp; 7 char c; 8 if((fp=fopen("file_data.txt","r"))==NULL){ 9 printf("打开文件失败\n"); 10 exit(0); 11 } 12 13 do{ 14 c=fgetc(fp); 15 putchar(c); 16 }while(!feof(fp)); 17 if(feof(fp)){ 18 printf("\n已经到达文件末尾\n"); 19 } 20 fclose(fp); 21 return 0; 22 }
C语言学习(43)
猜你喜欢
转载自www.cnblogs.com/Tobi/p/9239942.html
今日推荐
周排行