feof ()函数
语法:
1 2 |
?? #include <stdio.h> ?? int feof( FILE *stream ); |
函数feof()在到达给出的文件流的文件尾时返回一个非零值
feof是C语言标准库函数,其原型在stdio.h中,其功能是检测流上的文件结束符,如果文件结束,则返回非0值,否则返回0(即,文件结束:返回非0值,文件未结束,返回0值),文件结束符只能被clearerr()清除。(这里的检测流上的文件结束符就相当于声卡检测电流信号的一个过程)
1 2 3 4 5 6 7 8 9 10 11 12 |
#include<stdio.h> int main(void) { FILE *stream; /*open a file for reading*/ stream = fopen("DUMMY.FIL", "r"); /*read a character from the file*/ fgetc(stream); /*check for EOF*/ if(feof(stream)) printf("We have reached the end of file\n"); /*close the file*/ fclose(stream); return 0; } |