In the book Practical C Programming, I find that the combination of fgets() and sscanf() is used to read input. However, it appears to me that the
There is no difference between fscanf() versus fgets()/sscanf() when:
Two types of errors occur: I/O and format.
fscanf()simultaneously handles these two error types in one function but offer few recovery options. The separatefgets()andsscanf()allow logical separation of I/O issues from format ones and thus better recovery.
Separating I/O from scanning allows multiple
sscanf()options. Should a given scanning of a buffer not realize the desired results, othersscanf()with different formats are available.
'\0'.Rarely does
'\0'occurs, but should one occur,sscanf()will not see it as scanning stops with its occurrence, whereasfscanf()continues.
In all cases, check results of all three functions.