strtol c
# **strtol** | string to long integer | c library function
# EX.
# include <stdlib.h> // the library required to use strtol
int main() {
const char str[25] = " 2020 was garbage.";
char *endptr;
int base = 10;
long answer;
answer = strtol(str, &endptr, base);
printf("The converted long integer is %ld\n", answer);
return 0;
}
# ignores any whitespace at the beginning of the string and
# converts the next characters into a long integer.
# Stops when it comes across the first non-integer character.
long strtol(const char *str, char **endptr, int base)
# str − string to be converted.
# endptr − reference to an object of type char*, whose value is set
# to the next character in str after the numerical value.
# base − This is the base, which must be between 2 and 36 inclusive,
# or be the special value 0.