string -1 to int c++ code example Example 1: convert stirng to int c++ int thing = std::stoi(string); Example 2: c++ string to int atoi( str.c_str() )