You can check it with ferror(3), right after the while: while (EOF! = (ch = fgetc(fp))) // do something if (ferror(fp)! = 0) // error handling ferror returns a non-zero if an error occured If you want use fp after an error occured, you'll need to clear the error flag with clearerr: clearerr(fp).
You can check it with ferror(3), right after the while: while (EOF! = (ch = fgetc(fp))) // do something if (ferror(fp)! = 0) // error handling ferror returns a non-zero if an error occured.
If you want use fp after an error occured, you'll need to clear the error flag with clearerr: clearerr(fp).
– Oliver Weiler Nov 27 '10 at 16:59 5 @Helper Method: You just quoted that very statement in your manpage excerpt. – GregS Nov 27 '10 at 17:03.
Looping until fgetc returns EOF is perfectly fine. Afterwards, if you want to know whether the loop ended due to simply reaching the end of the file or due to an error, you should call ferror. If you don't care you can skip the call to ferror.
This is what the specs say: the fgetc() function shall obtain the next byte as an unsigned char converted to an int The following macro name shall be defined as a negative integer constant expression: EOF As long as you store the return value in an int and not a char, it is sufficient to check for EOF because it is guaranteed not to represent a valid character value. Also, in your code, this: while (ch = fgetc(fp)! = EOF) should be: while ((ch = fgetc(fp))!
= EOF) The additional parentheses are required because! = has higher precedence than =.
As long as you store the return value in an int and not a char, it is sufficient to check for EOF because it is guaranteed not to represent a valid character value. The additional parentheses are required because! = has higher precedence than =.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.