according documentation:
On success, the function returns the converted integral number as a long int value. If no valid conversion could be perfor
Since the accepted answer is not actually a correct way to check for failure.
You should not check for errors by examining the return value of strtol, because the string might be a valid representation of 0l, LONG_MAX, or LONG_MIN. Instead, check whether tailptr points to what you expect after the number (e.g. '\0' if the string should end after the number). You also need to clear errno before the call and check it afterward, in case there was overflow.