For puts (const char*)
, I read that, "On success, a non-negative value is returned. On error, the function returns EOF and sets the error indicator (ferror)."
I'm trying to get the function to error so I can cout
the EOF return, but I can't seem to. If I don't initialize the char*
to anything, or set it to NULL, it still returns a non-negative success value. What is something that would actually make this function fail? Thanks.
Side question: If you cout <<
a function that's supposed to return EOF, will it actually print 'EOF', something else, or nothing? This is actually what I was trying to test in the first place.
stdout
. – Kerrek SBFILE
object is indeterminate after it is closed. – dreamlaxcout << EOF << endl
; it will simply print a negative number, e.g.-1
. Functions that return EOF typically have the return typeint
, so it simply calls the<<
overload forint
. – dreamlax