【发布时间】:2020-04-17 11:00:48
【问题描述】:
例如这个数据文件abc.txt
abc
注意底部没有换行符。
当我用 C 编写以下程序时
#include <stdio.h>
int main(){
FILE *fp = fopen("abc.txt","rb"); // NOTE this is "rb"
while (!feof(fp)){
fprintf(stdout, "%c", fgetc(fp));
fprintf(stdout, "%d", feof(fp));
}
fclose(fp);
return 0;
}
标准输出结果是这样的:
[xxx@xxx hello]$ ./a.out
a0b0c0
0�1[xxx@xxx hello]$
最后一行的额外输出字节数是多少?
【问题讨论】:
标签: c file binaryfiles eof stdio