【发布时间】:2014-11-02 08:45:06
【问题描述】:
所以我有一个已读取的文件。用户可以指定一次打印多少字节。
目前我有:
while(fread(buffer, bytes, 1, txtFile) != '\0')
printf("%s\n", buffer);
但是,如果它首先到达 EOF,它会切断最后一行。例如,如果 bytes = 12 ,则打印:
How the migh
ty have fall
...但我希望它打印出来:
How the migh
ty have fall
en!
相反。这样做的正确方法是什么?
【问题讨论】: