小编rax*_*it 的帖子

fgetc不识别EOF

下面的程序在各种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)

c aix types eof fgetc

6
推荐指数
1
解决办法
2301
查看次数

标签 统计

aix ×1

c ×1

eof ×1

fgetc ×1

types ×1