string to int c

C
atoi(str) is unsafe

This is the prefered method:
(int)strtol(str, (char **)NULL, 10)
Source

Also in C: