while (true) {
// Display the players location and possible movements.
cout << "------------------" << endl;
cout << "Location: " << NewUser.location->name << endl;
cout << "\nDescription: " << NewUser.location->description << endl;
if (NewUser.location->north)
cout << "(N)orth to: " << NewUser.location->north->name << endl;
if (NewUser.location->south)
cout << "(S)outh to: " << NewUser.location->south->name << endl;
if (NewUser.location->east)
cout << "(E)ast to: " << NewUser.location->east->name << endl;
if (NewUser.location->west)
cout << "(W)est to: " << NewUser.location->west->name << endl;
cout << "(Q)uit" << endl;
// Get input and decide where to go next.
char input;
cin >> input;
if (input == 'n' && NewUser.location->north)
NewUser.location = NewUser.location->north;
if (input == 's' && NewUser.location->south)
cout << quizMaster.poseQuestion().c_str() << endl;
getline(cin, answer);
if (quizMaster.isCorrectAnswer(answer))
cout << "Thats right" << endl;
else
cout << "Better luck next time !" << endl;
NewUser.location = NewUser.location->south;
if (input == 'e' && NewUser.location->east)
NewUser.location = NewUser.location->east;
if (input == 'w' && NewUser.location->west)
NewUser.location = NewUser.location->west;
if (input == 'q')
break;
}
delete [] rooms;
Here is my loop.
Now if I put
cout << quizMaster.poseQuestion().c_str() << endl;
getline(cin, answer);
if (quizMaster.isCorrectAnswer(answer))
cout << "Thats right" << endl;
else
cout << "Better luck next time !" << endl;
This in all of the other directions, it gets stuck saying better luck next time and then exe freezes and closes.
I have the full code which relates to the above as a attatchement.
Any Ideas?
Thanks in advance.