feof函数
The function feof() tests the end-of-file indicator for the stream pointed to by stream, returning nonzero if it is set.
feof是用于测试当前是否文件末尾。若是末尾返回非0值。
例子
// test.c    
#include <stdio.h>
int main()
{
    FILE *f = fopen("empty_file", "rb");
    if (f == NULL) {
        return -1;
    }
    while (!feof(f)) { // 判断是否文件末尾,若不是读取一个字节,然后输出
        char c;
        int ret = fread(&c, 1, 1, f);
        printf("%d-%x\n", ret, c);
    }
    printf("eof\n");
}
执行命令:
touch empty_file #创建空文件
gcc -o test test.c # 编译上述文件
localhost:~/Desktop$ ./test 
0-75 #执行结果:fread返回值 和 c的值
eof
localhost:~/Desktop$ ./test 
0-ffffffb6 #执行结果:fread返回值 和 c的值
eof
ocalhost:~/Desktop$ ./test 
0-34 #执行结果:fread返回值 和 c的值
eof
从上面例子可以看到,对于空文件来说,feof第一次返回值为0,即为非文件末尾,在使用fread读取文件时返回值为0,表示没有读到内容,第二次feof返回值为非0,退出while循环。
总结
PREVIOUSARM中的STM和LDM指令的解析