fgetc reads a character from a file at a time, and returns the character as type of int. If the file ends, then fgetc returns EOF ("probably" (int)(-1)). However, I have seen this so frequently:
char ch;
while ((ch = fgetc(fp)) != EOF) { /* Do something. */ }
|<-- PARN -->|
This is what I concern:
fgetcreadsOxFFand returns0x000000FF.0xFFis assigned toch. (type casting frominttochar)- If
PARNis type ofchar, then it will be promoted to0xFFFFFFFF. - Break out of the while loop because
PARN == EOF. (stop reading from the file)
How can we tell reading OxFF and returning EOF apart?