Comparing unsigned char and EOF
问题 when the following code is compiled it goes into an infinite loop: int main() { unsigned char ch; FILE *fp; fp = fopen(\"abc\",\"r\"); if(fp==NULL) { printf(\"Unable to Open\"); exit(1); } while((ch = fgetc(fp))!=EOF) printf(\"%c\",ch); fclose(fp); printf(\"\\n\",ch); return 0; } The gcc Compiler also gives warning on compilation abc.c:13:warning: comparison is always true due to limited range of data type the code runs fine when unsigned char is replaced by char or int as expected i.e. it