What is the difference between atol() & strtol()?
According to their man pages, they seem to have the same effect as well as matching arguments:
In new code I would always use strtol
. It has error handling and the endptr
argument allows you to see which part of the string was used.
The C99 standard states about the ato*
functions:
Except for the behavior on error,they equivalent to
atoi: (int)strtol(nptr,(char **)NULL, 10)
atol: strtol(nptr,(char **)NULL, 10)
atoll: strtoll(nptr, (char **)NULL, 10)