Original Post
Hello, I'm trying to figure out why this While loop runs. If I type 1 or 2 it still goes through the while loop, I have no idea why? What I'm trying to do is check for input of 1 or 2, I have used char as well for this. If it doesn't equal 1 or 2 repeat loop and ask for input. I would use a switch if I knew how after checking case '1' (if you use a char) and case '2' then at default: have it ask for input then loop the switch until either 1 or 2 was typed. What should happen is if 1 or 2 is pressed the program should quit. Please ignore my other code, just look at the while (). I have code I still need to add.
#include <iostream>
#include <stdlib.h>
#include <string>
#include "Mage.h"
#include "Warrior.h"
// Globals
// -----------------
int Health;
int Defence;
int Attack;
// -----------------
using namespace std;
int main()
{
// Title
cout << "********************\n Text Game\n********************\n\n";
system ("pause");
cout << "*********\n Menu\n*********\n\n1) Start\n2) Quit\n\n";
// Check Menu Input
string MenuCheck = "";
cin >> MenuCheck;
while (MenuCheck != "1" || "2")
{
if (MenuCheck == "1")
{
cout << "Starting Game ...\n";
system ("pause");
return 0;
}
else if (MenuCheck == "2")
{
return 0;
}
else
{
cout << "Invaild Input! Try Again.\n";
cin >> MenuCheck;
}
}
return 0;
}
// Game Start
void StartGame()
{
system ("cls");
cout << "STARTING GAME ...";
system ("pause");
}