convert string to integer c code example
Example 1: string to int c
atoi(str) is unsafe
This is the prefered method:
(int)strtol(str, (char **)NULL, 10)
Example 2: how to cast string to int in c
use atoi from the stdlib.h
char *string = "hi";
int x = atoi(string);