Convert string to int 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: convert stirng to int c++
int thing = std::stoi(string);
Example 3: c convert char to int
int i = (int)(c - '0');
Example 4: how to cast string to int in c
use atoi from the stdlib.h
char *string = "hi";
int x = atoi(string);