我有一个非常简单的main.cpp文件:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = "194";
int i = stoi(s);
cout << i << endl;
}
在命令行clang++ main.cpp -std=c++11
输出:
main.cpp:6:10: error: use of undeclared identifier 'stoi'
int i = stoi(s);
^
1 error generated.
和clang++ --version
输出:
clang version 3.6.1 (tags/RELEASE_361/final)
Target: i686-pc-windows-gnu
Thread model: posix
通过GCC,g++ main.cpp -std=c++11
输出:
main.cpp: In function 'int main()':
main.cpp:6:16: error: 'stoi' was not declared in this scope
int i = stoi(s);
^
g++ --version
输出:
g++ (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
我已尝试查找类似问题的答案,但似乎没有一种解决方案可行。
可能是什么问题?