I need help with Strings! Thanks in advance!

The line has I underlined has an error message of Bathtub not being declared. I want it to be able to recognize if someone types bathtub into the program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #include <iostream>

int main(){
using namespace std;
int x;
string answer ;
cout<<"Welcome to Jumble!";
cout<< endl;
cout<<"We have over 1 words to unjumble!";
cout<< endl;
cout<<"Select a number. Each number represents a puzzle.";
cout<< endl; 
cout<<"After Selection, you will see a word. Type it in its unjumbled form.";
cout<< endl;
cout<< "Type a number!";
cout<< endl;
cin>> x;

if (x==1){
cout<< endl;
cout<< "Your word is: bthabtu";
cin>> answer;
if(answer==bathtub){
	cout<< endl;
	cout<< "You are correct!";
}
The compiler assumes that bathtub is the identifier (name) of a variable, because you didn't use quotes ("").
You always use quotes for string literals - it's no different than the text you're printing using std::cout.
Topic archived. No new replies allowed.