A simple question, and I am about 99.99% sure of the answer but seeking some feedback so I can feel 100% confident in my understanding. When fputc
returns EOF
it is only on stream error correct? For example, say I have a very small space to write to, and the end of space is reached, fputc
would return EOF
as an error and not actually end-of-file? In other words, something like this is not required?
ch = fputc(c, stream);
if(ch == EOF) {
if(ferror(stream)) {
// error
} else {
// EOF
}
}
Because if fputc
returns EOF
it is safe for me to assume that ferror(stream)
will always return non-0?
I searched for answers on here, and I apologize if this is a duplicate question, but I am relatively new on here and haven't quite mastered the art of searching the knowledge base yet.