下面的程序在各种Solaris/Linux版本上运行良好,但在AIX上运行不正常.不过,如果我更换while(c!=EOF)与while(c!=0xff)AIX上运行完全正常.
有什么想法吗?我检查了AIX上的fgetc手册页,它应该返回EOF常量!
#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;
}
Run Code Online (Sandbox Code Playgroud)