This question already has an answer here:
The program below runs fine on various Solaris/Linux flavours, but not on AIX.
However, if I replace while(c!=EOF)
with while(c!=0xff)
on AIX it runs completely fine.
Any thoughts? I checked the fgetc man page on AIX, and it should return the EOF constant!
#include <stdio.h>
#include<unistd.h>
#include <string.h>
int main() {
char c;
FILE *fp;
fp = fopen("a.txt", "r");
c=fgetc(fp);
while(c!=EOF)
{
c=fgetc(fp);
printf("%d",c);
}
fclose(fp);
return 0;
}
来源:https://stackoverflow.com/questions/3977223/fgetc-does-not-identify-eof