Hey guys. I have a another problem, but I can't fix this one. I've tried for hours. I'm going to post 2 pieces of code. I need "If this condition is met, then go back to where i == 0". I'll show you.
while ( i == 0)
{
if (strcmp(userInput, north) == 0)
{
cout << "\nYou walk north!\n";
i == 1;
}
else if (strcmp(userInput, south) == 0)
{
cout << "\nYou walk south!\n";
i == 2;
}
else if (strcmp(userInput, east) == 0)
{
cout << "\nYou walk east!\n";
i == 3;
}
else if (strcmp(userInput, west) == 0)
{
cout << "\nYou walk west!\n";
i == 4;
}
else
{
cout << "You must enter a Direction Command!\n";
}
So this is my first piece of code.
Here is my second.
do
{
cout << "You arrive upon a scary looking cave.\n";
cout << "Will you go inside?\nType IN to go inside, or type the SOUTH command to go back to where you started.\n";
cin >> userInput;
if (strcmp(userInput, in) == 0)
{
cout << "\n\nYou walk into the cave very cautiously!\n";
cout << "\nAs fast as a cheetah, an Ogre jumps out and slashes at your face!";
i == 5;
}
else if (strcmp(userInput, south) == 0)
{
cout << "\nYou walk south!\n";
i == --i;
}
}while ( i == 1 );
Whenever the (strcmp(userInput, south) == 0) it shows the user "You walk south!". But at that point in time, I need it to jump back to the first piece of code. Help me please!