...
- do not need to set
errno
on an error - have undefined behavior if the value of the result cannot be represented (see undefined behavior 113 of Annex J of C99)
- some implementations return 0 if the string does not represent an integer , (which is indistinguishable from a correctly formatted, zero-denoting input string) but C99 only specifies the behavior of these functions on success.
Compliant Solution (strtol()
)
...