views:

42

answers:

1

Below program runs fine on solaris/linux various flavor, but not on AIX. on AIX while(c!=EOF) if i replace by while(c!=0xff) it just run fine completely

Any thought ? i checked the man page of fgetc on aix, and it should return 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;
}
+12  A: 

The return value of fgetc is int not char. So change

char c;

to

int c;
codaddict