#include <iostream>
#include <string>
int main()
{
std::string test = "45";
int myint = stoi(test);
std::cout << myint << '\n';
}
I tried this code on my computer which is running MinGW GCC 4.7.2. It gives me this error:
What am I doing wrong, I got this from cppreference. Its the exact same code. And its a different error from the one described here.
It seems your MinGW needs a patch: Enabling string conversion functions in MinGW
This patch enables the following list of C++11 functions and templates in the std namespace:
stoi, stol, stoul, stoll, stof, stod, stold, to_string, to_wstring
In above link, there is a .zip
file, download it and
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