我当前有一个文件,它将新条目附加到当前文件中。我想获取最近的 5 个条目。在C语言中如何先读取最后一行?如果可能的话,我想使用 fgets 命令逐行读取。
感谢您的帮助!
编辑: 例如:
原始文件:
The cat is fast.
Dogs are cool.
I like pie.
期望的输出:
I like pie.
Dogs are cool.
The cat is fast.
最佳答案
while(fgets(buffer,sizeof(buffer),fp); //go on scanning lines
//Now `buffer` holds the last line of `fp`
关于c - 在 C 中首先读取文件的最后一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29057720/