May someone tell me why my code is not working correctly, when I attempt to compile it it gives me the error of not being able to transfer the
"if (decisiondata = 1)" into a bool (I'm assuming that means boolean term).
#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
int main ()
{
//beginning sequence
usingnamespace std;
string namedata;
cout << "SINBAD: You traveller, what is your name?" << endl;
cout << "NAME: ",
getline(std::cin, namedata);
cout << "SINBAD: Well " << namedata << " you will be the first man I slay today, feel privileged." << endl;
string decisiondata;
cout << "{-} You carefully approach Sinbad and prepare yourself." << endl;
cout << "{-} [1] Fight or [2] Run" << endl;
cout << "{-} What will you choose ?: "; getline (cin,decisiondata);
if (decisiondata = 1)
return 0;
}
1 is a number "1" is a string literal
decisiondata is a std::string.
A std::string does not evaluate to true or false
> it gives me the error of not being able to transfer the "if (decisiondata = 1)" into a bool
if you don't understand the error message, don't paraphrase it, post it fully
foo.cpp:19:6: error: value of type 'std::basic_string<char>' is not contextually convertible to 'bool'