In C ++, the string is converted to a digital several ways. But the string header file provides the easiest option.
Using std :: stoi () function to convert the string to an integer specified:
std::string s{"123"};
int i{ std::stoi(s) };
Similarly, string header file provides stol (), stoll (), stoul (), stoull (), stof (), stod () and STOLD () function, which are included in the std namespace, respectively character string into a long, long long, unsigned long, unsigned long long, float, double, and long double type.