Hi all,
I am getting the following error when compiling. It does not recognize the declaration intNumberGuessed above i am guessing.
prog.cpp:29:20: error: use of undeclared identifier 'stod'
intNumberGuessed = stod(numberGuessed);
^
1 error generated.
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
int main(){
string numberGuessed;
int intNumberGuessed = 0;
do{
cout << "Guess a number between 1 and 10: ";
getline(cin, numberGuessed);
intNumberGuessed = stod(numberGuessed);
cout << intNumberGuessed << endl;
}while(intNumberGuessed != 4);
cout << "You win!" << endl;
return 0;
}
Last edited on
http://en.cppreference.com/w/cpp/string/basic_string/stof
(since C++11)
compile it on ideone with version c++14!
It works :)
Thanks a lot!