Good day! I saw a thread about "foef" and "EOF", and since the post were short and clear I like to ask for something.
When should we use "feof ()"?
Good day! I saw a thread about "foef" and "EOF", and since the post were short and clear I like to ask for something.
When should we use "feof ()"?
feof() reads the internal state of the stream and returns something non-zero if the end-of-file is set. This state is set by all input functions such as fgets(), fscanf(), etc. Sometimes these can fail before reaching the end, in case of a file error for example. If you're looping by using the return value of fscanf(), with feof() you could check if you actually reached the end of the file before exiting and either try again or print an error message.
Devoted my life to programming...