That's the signature of strtol():
long int strtol(const char *nptr, char **endptr, int base);
If endptr
is not NULL, strtol()
stores the address of the first invalid character in *endptr
.
So you can simply compare *endptr
to nptr
afterwards and if it differs, strtol()
has parsed the characters before *endptr
.