首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

怎么判断当前读的数据是文件中最后一个

2013-03-06 
如何判断当前读的数据是文件中最后一个date.txt文件有约100个int 型数据。现在想把它一个一个读出来,但是怎

如何判断当前读的数据是文件中最后一个
date.txt文件有约100个int 型数据。现在想把它一个一个读出来,但是怎么知道什么时候读到的数据是最后一个。
[解决办法]
用feof函数进行判断。
[解决办法]
char *fgets(char *s, int n, FILE *stream)
fgets reads at most the next n-1 characters into the array s, stopping if a newline is encountered; the newline is included in the array, which is terminated by '\0'. fgets returns s, or NULL if end of file or error occurs.
[解决办法]
文件的末尾有一个标志 读取到的数值为 EOF 表示到文件末尾
[解决办法]
!= EOF

热点排行