#include <iostream>
using namespace std;
int main ()
{
string a;
cin >> a;
int b=10;
cout << a+b;
return 0;
}
I have a problem with the code above. I know it's wrong, but it shows my point.
I'm wondering if I get a number as a string, how can I have it as an integer? For example, I give 12
to the program after running. So a
will be "12"
. Now I want the summation of 12 and the variable b
. What should I do? How can I extract 12 as an integer from my string?