Hello everyone. I need help with a variable.Here is my code. For some reason the string variable isn't working when i type the correct answer. I think it's because the answer contains two words, but i don't know how to make it work. If someone knows, pls tell me. Thanks!
#include <iostream>
usingnamespace std;
int main()
{
string answer1;
cout << "Hi There! This is a Movie Quiz #1. Hope you enjoy it. Let's get started!" << endl;
cout<<"We all know the movie called 'Friday The 13th' aren't we?Tell me the first and the last name of the killer in this movie"<<endl;
cin>>answer1;
if (answer1=="Pamela Voorhees")
cout<<"True! Jason was ruled by his mother, so she is the real killer!"<<endl;
else
{
cout<<"False! Jason was ruled by his mother, so this make her the real killer in the movie!"<<endl;
return 1;
}
cout<<"Next question!"<<endl;
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
cout << "Hi There! This is a Movie Quiz #1. Hope you enjoy it. Let's get started!" << endl;
cout<<"We all know the movie called 'Friday The 13th' aren't we?Tell me the first and the last name of the killer in this movie"<<endl;
string answer1;
cin>>answer1;
getline(cin, answer1);
if (answer1=="Pamela Voorhees")
cout<<"True! Jason was ruled by his mother, so she is the real killer!"<<endl;
else
{
cout<<"False! Jason was ruled by his mother, so this make her the real killer in the movie!"<<endl;
return 1;
}
cout<<"Next question!"<<endl;
return 0;
}