On success, the function returns the converted integral number as a
long int value. If no valid conversion could be performed, a zero
value is returned. If the correct value is out of the range of
representable values, LONG_MAX or LONG_MIN is returned, and the global
variable errno is set to ERANGE.
Consider strtol(str, (char**)NULL, 10); if str is "0\0" how to know if the function failed or only has converted the string with "0" number?
You need to pass a real pointer address if you want error checking, so you can distinguish 0 values arising from
"0"and similar from 0 values arising from"pqr":