I have a case where I\'m not sure if I\'ll get enough input for sscanf
. Can I safely assume that sscanf
won\'t mess with any argument that it doesn
Guranteed. sscanf() will not assign any thing to the extra parameters. You can avoid checking for the return value for this
The C library function int sscanf(const char *str, const char *format, ...)
reads formatted input from a string instead of stdin
On success, the function returns the number of items in the argument list successfully filled.
On failure, This count can match the expected number of items or be less (even zero) in the case of a matching failure.
In the case of an input failure before any data could be successfully interpreted, EOF is returned.
If there are too many arguments for the conversion specifications, the extra arguments are evaluated but otherwise ignored.
The results are not defined if there are not enough arguments for the conversion specifications.
All three functions (fscanf, scanf, and sscanf) return
the number of input items that were successfully matched and assigned. The return value does not include conversions that were performed but not assigned (for example, suppressed assignments).
If you check with the Number of Items count That might become false in some cases.