I come from other programming languages and I don't understand why this code throws error.
string n = "123456";
int x;
for(int i = 0; i < n.length(); i++) {
x = atoi( n[i].c_str() );
x *= 2;
cout << x << endl;
}
Can you explain me this accident? And show me how to convert it into integer properly?