Hoping someone can help me... I'm a C++ noob and I'm writing a simple "text adventure" (older members will know what that is!!) to help hone my skills (if that's what they can be called at this stage!).
However I'm having two problems with the below member function:
Firstly, the program is not recognising the link between choice and "open door" if I type in "open door" in the resulting console - it skips and goes straight to the else section. I have tried replacing the type of 'choice' from string to char* and using strcmp - however this didn't make any difference.
void Office::user_input(door* pDoor, object* pObject, object* pFurniture, Room* pRoom)
bool exit = false;
for ( ; ; )
cout << "What would you like to do? ";
cin >> choice;
if (choice=="open door")
cout << "Not to worry, this is only a test.";
Secondly, for some reason after typing in your command it is looping twice, ie printing "not to worry, this is only a test" and "what would you like to do?" twice before pausing to let the user type in their command again.
I don't know if the two problems are related (although it seems doubtful). If anyone could shed any light it'd be really helpful. Cheers!