Versions Compared

Key

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

...

Instead of these functions, try inputing the value as a string and then converting it to an integer valoue value using strtol() or a related function INT00-A.

...

This non-compliant example uses the scanf() function to read a string from stdin and covert convert it to an integer value. The scanf() and fscanf() functions have undefined behavior if the value of the result of this operation cannot be represented as an integer.

...

The following compliant example uses the fgets() to input a string and strtol() to convert the string to an integer value. Error checking is provided to make sure that the value is a valid integer in the range of int.

...