char 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: char to int c++
int x = (int)character - 48;
Example 3: turn a char into an int in c
int x = character - '0';
Example 4: int to char in c
c = i +'0';
Example 5: char* to int in cpp
int x = std::stoi("42")
Example 6: c convert char to int
int i = (int)(c - '0');