type conversion from char to int in c++ code example Example 1: char* to int in cpp int x = std::stoi("42") Example 2: convert char to int c++ int x = character - '0'