This is a basic question. I use C++ but not C++11. Now, I want to convert a string to an integer. I have declared like this:
string s;
int i = atoi(s);
However, this shows an error that such a conversion is not possible. I checked out the internet and I found that C++11 has stoi() but I want to use atoi itself. How can I do it? Thanks!
Convert it into a C string and you're done
string s;
int i = atoi(s.c_str());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With