(newbie) converting string to int..
I'm trying to convert string to int with atoi, but I always get this error when I try to compile:
test.cpp: In function ‘int main()’:
test.cpp:11: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’
Code:
int main() {
cout<<"insert string\n";
string a;
cin>>a;
int b=0;
while(a!="s") {
b=atoi(a);
cout<<b<<"\n";
cin>>a;
}
}
This is prototype, no checking if string is not number or smth.. How to make this prototype to work? :(