{{keywords>wiki library source code example reference}} ====== strtol ====== #include long int strtol(const char *str, char **endptr, int base); strtol Converting a string to an long integer\\ str: the string to be converted\\ endptr: address of a pointer variable that points to the last character read, so the character that is not owned by a number\\ base: base between 2 and 36\\ \\ Be found unprefixed numbers, these numbers in base 10 are accepted.\\ If the base '0 'is specified, the strings make a reference to the basis used\\ (leading "0x" for hexadecimal, "0" for octal, numbers).\\ ===== strtol c code example ===== /* * strtol example code * http://code-reference.com/c/stdlib.h/strtol */ #include #include int main ( void ) { char string[] ="20405"; char *endptr; long int number; number = strtol(string, &endptr, 10); printf("string is %s\n",string); printf("long int is %li\n", number); return 0; } ==== Output ==== user@host:~$ ./strtol string is 20405 long int is 20405