std::stoi converts text containing digits into an integer value the program can calculate with.

Parse Integer Text

parse_integer_text.cpp
#include <iostream>
#include <string>

int main() {
    std::string text = ;

    int value = std::stoi(text);
    int doubled = value * 2;

    std::cout << "value=" << value << std::endl;
    std::cout << "doubled=" << doubled << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    std::string text = ;

    int value = std::stoi(text);
    int doubled = value * 2;

    std::cout << "value=" << value << std::endl;
    std::cout << "doubled=" << doubled << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    std::string text = ;

    int value = std::stoi(text);
    int doubled = value * 2;

    std::cout << "value=" << value << std::endl;
    std::cout << "doubled=" << doubled << std::endl;
    return 0;
}
stoi `std::stoi` parses a string and returns an `int`.
parsed value After parsing, the value behaves like any other integer.