Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Wiki MarkupAlternatively, input character data as a null-terminated byte string and convert to an integer value using {{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

...