5
为什么“ while(!feof(file))”总是错误的?
我最近在很多帖子中都看到有人试图读取这样的文件: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *path = "stdin"; FILE *fp = argc > 1 ? fopen(path=argv[1], "r") : stdin; if( fp == NULL ) { perror(path); return EXIT_FAILURE; } while( !feof(fp) ) { /* THIS IS WRONG */ /* Read and process data …
573
c
file
while-loop
eof
feof