Hi I am new to C++ and I'm trying to create a console program that quizzes you using some of my old quizzes. My only problem is when I get to questions where there are spaces between the word it messes up. Here's an example:
string answer1 = "anything\0that\0has\0mass\0and\0occupies\0space";
string userresponse1;
cout << "1. Define matter.\n";
cin >> userresponse1;
if (userresponse1 == answer1)
{
cout << "Correct" << endl;
score += 1;
}
else
{
cout << "Incorrect" << endl;
}
I enter the answer, but it goes ahead and and answers the next question and the one following that. My question is can you compare strings with spaces in it?