I have a question about the fgets()
char *fgets(char *str, int strsize, FILE *stream);
fgets()' document says:
On success, the function returns the same str parameter. If the End-of-File is encountered and no characters have been read, the contents of str remain unchanged and a null pointer is returned.
If an error occurs, a null pointer is returned.
How do you differentiate between above two situations - fgets reaching EOF(END OF FILE) & error whilst reading file?
Also, when an error occurs whilst fgets reads file, does fgets keep track of whatever has been read up to that point in the str?
How do you check if fgets immediately reaches EOF?