#include <iostream>
#include <string>
int main()
{
std::string test = "45";
int myint = stoi(test);
std::cout << myint << '\n';
}
Run Code Online (Sandbox Code Playgroud)
我在运行MinGW GCC 4.7.2的计算机上试过这段代码.它给了我这个错误:

我做错了什么,我从cppreference得到了这个.它完全相同的代码.它与此处描述的错误不同.
mas*_*oud 15
你的MinGW似乎需要一个补丁:在MinGW中启用字符串转换功能
此修补程序在std命名空间中启用以下C++ 11函数和模板列表:
stoi,stol,stoul,stoll,stof,stod,stold,to_string,to_wstring
在上面的链接中,有一个.zip文件,下载它