此代码无法编译,并显示无法解决stio的错误。我在这里犯了一些新手错误吗?
Eclipse版本:3.8.1 Mint KDE应该都是最新的。
GCC版本:gcc(Ubuntu 5.4.0-6ubuntu1〜16.04.10)5.4.0 20160609
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <vector>
using namespace std;
int main() {
string numberGuessed;
int intNumberGuessed = 0;
int answer = 0;
answer = (rand() % 100) + 1;
do {
cout << "Guess a number "; // prints !!!Hello World!!!
getline(cin, numberGuessed);
intNumberGuessed = stoi(numberGuessed);
cout << "You guessed "<< numberGuessed << endl;
cout << "You are not correct. Try again" << endl;
} while (answer != intNumberGuessed);
cout << "you got it";
return 0;
}
错误消息。
16:39:14 **** Incremental Build of configuration Debug for project Hello2 ****
make all
Building file: ../src/Hello2.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Hello2.d" -
MT"src/Hello2.d" -o "src/Hello2.o" "../src/Hello2.cpp"
../src/Hello2.cpp: In function ‘int main()’:
../src/Hello2.cpp:27:40: error: ‘stoi’ was not declared in this scope
intNumberGuessed = stoi(numberGuessed);
^
make: *** [src/Hello2.o] Error 1
src/subdir.mk:18: recipe for target 'src/Hello2.o' failed
16:39:14 Build Finished (took 613ms)