1atoi(str) is unsafe
2
3This is the prefered method:
4(int)strtol(str, (char **)NULL, 10)
1const char *number = "10";
2char *end;
3long int value = strtol(number, &end, 10);
4if (end == number || *end != '\0' || errno == ERANGE)
5 printf("Not a number");
6else
7 printf("Value: %ld", value);