Do not use functions that input characters and convert them to integers if the functions cannot handle all possible inputs. For example, formatted input functions such as scanf()
, fscanf()
, vscanf()
, and vfscanf()
can be used to read string data from stdin
or (in the cases of fscanf()
and vfscanf()
) other input streams. These functions work fine for valid integer values but lack robust error handling for invalid values.
Alternatively, input character data as a null-terminated byte string and convert to an integer value using {{ Wiki Markup strtol()
}} or a related function \[[function (see INT06-A. Use strtol() or a related function to convert a string token to an integer]\]).
Non-Compliant Code Example
...