int main(int argc, char *argv[])
{
int choice;
string username, i;
string susername;
string password;
string Spassword;
int life, guess, random;
random = rand() % 10 + 1;
life = 10;
cout<<"This is a text based game. Always answer Yes or No questions with Y or N\n";
cout<<"Guess a number between 1 and 10,\n";
cout<<"and with every guess, your life decreases by one.\n";
cout<< "\n\nPick a number between 1 and 10.\n";
cout<< "You have " << life <<" lives.\n";
cin>> guess;
while (guess < random)
{
cout<< "Bigger!\n";
cin.get();
}
while (guess > random)
{
cout<< "Smaller!\n";
cin.get();
}
while (guess > 10)
{
cout<< "I said 1 - 100!\n";
cout<< "You neglected to follow directions. YOU LOSE.\n";
life = 0;
cin.get();
return 0;
}
while (guess < 0)
{
cout<< "I said 1 - 100!\n";
cout<< "You neglected to follow directions. YOU LOSE.\n";
life=0;
cin.get();
return 0;
}
if (guess == random)
{
cout<<"GOOD JOB :D\n";
cout<<" ____________\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| SUCCESS |\n";
cout<<"| |\n";
cout<<"|____________|\n";
std::cin >> i;
cout<<"Good job.\n";
pbg();
}
if (choice == 2)
{
cout<<"Wow! You managed to lose the game, it hasnt even started!";
cin.ignore();
cin.ignore();
return 0;
}
There is no such thing as in "if loop." What you want is those statements to be if statements, and have a larger while loop around the entire program (what you want to repeat). Obviously you don't want to repeat the text over and and over again, so don't put a while loop around it.