You can use:
long int strtol(const char *nptr, char **endptr, int base);
Then check if *endptr != nptr
. This means that the string at least begins with the integer.
You can also check that *endptr points to terminating zero, which means that the whole string was successfully parsed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…