In C++, the stoi() function is useful to change strings to integers. Basically, it only needs one parameter, and it is like stoi(something).
Example:
#include <iostream>
using namespace std;
int main()
{
string x;
cin >> x;
cout << stoi(x) + 1; // prints the input + 1
}
Example Output:
>>> 1
<<< 2
And that’s all! In short, stoi() is a function that converts strings into integers.