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
You are completely safe.
In C11, 7.21.6.7 The sscanf function
2. ...Reaching the end of the string is equivalent to encountering end-of-file for the fscanf function.
7.21.6.2 The fscanf function says,
4. The fscanf function executes each directive of the format in turn. When all directives have been executed, or if a directive fails (as detailed below), the function returns. Failures are described as input failures (due to the occurrence of an encoding error or the unavailability of input characters), or matching failures (due to inappropriate input).
16. The fscanf function returns the value of the macro EOF if an input failure occurs before the first conversion (if any) has completed.Otherwise, the function returns the number of input items assigned.
Your case is an input failure.