fscanf returns EOF in case of errors or if it reaches eof.


what does error mean in this context ...which type of errors are encountered???

Recommended Answers

fscanf returns EOF in case of errors or if it reaches eof.

Specifically, it returns EOF if an "input failure" occurs before any conversion. Otherwise it returns the number of successful conversions which may be as few as zero.

"Input failure" basically means anything that isn't a matching failure …

Jump to Post

All 2 Replies

fscanf returns EOF in case of errors or if it reaches eof.

Specifically, it returns EOF if an "input failure" occurs before any conversion. Otherwise it returns the number of successful conversions which may be as few as zero.

"Input failure" basically means anything that isn't a matching failure for the format specifier. For example, the stream being pointed to a removable drive that was unplugged in between opening the stream and calling fscanf() would constitute an input failure while an invalid integer being matched by the %d specifier would be a matching failure.

To be precise, an error must occur before any conversion took place. Errors in question are numerous. For a posix system, you may want to read an ERRORS section of man fscanf

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.