Some operations to read and write from streams may set the error flag in a stream, which can be tested using ferror(stream)
, while I'm quite sure this must be a frequently asked question, I wasn't able to find a list of all the possible causes of errors in SO or in the general web. What could cause ferror() to be set?
In particular, I'm looking for the possible causes of errors when doing fgets() on the standard input on Minix 3, but I'm looking for a more general list as well.
perror()
to get a more descriptive error info – Yalondaferror()
is not supposed to updateerrno
if the stream is in error, so it's probably too late to useperror()
. @lie-ryan must useperror()
after failedfgets()
call. – Ladonman 3 ferror
ferror() never fails or sets the errno so it should be ok ,fgets would have set theerrno
. – Yalonda