I need to write a program for class that requires me to convert numbers in a string to integers. So I wrote a sample program to try to figure out how to but when I try to compile it I get a massive influx of errors. I'm not sure what I'm doing wrong and any help would be greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string st;
cout << "Enter numbers: ";
cin << st;
for (int i = 0; i < st.length(); i++)
{
st[i] = st[i] - '0';
}
}