Versions Compared

Key

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

...

  • do not need to set errno on an error
  • have undefined behavior if the value of the result cannot be represented
  • return 0 if the string does not represent an integer, which is indistinguishable from a correctly - formatted, zero-denoting input string.

...

The sscanf() function does return the number of input items successfully matched and assigned, which can be fewer than provided for, or even zero in the event of an early matching failure. However, sscanf() fails to report the other errors reported by strtol(), such as overflow.

Compliant Solution

...