Help with infinite prompt loop

So im creating a roulette program for fun and have finished it, just adding smaller details and have come across a problem where its prompting the user infinitely, cant seem to see whats wrong. was running fine until this point where i wanted to prompt the user to try again if they input something other than the acceptable characters.
[code]
#include <iostream>
#include <cmath>
#include <string>
#include <ctime>
#include <limits>

using namespace std;

int main()
{
srand(time(0));
int currency = rand()% 1000 + 1;
int bet;
char playG;
int betN;
int wNum;
char cont;
int cCounter = 0;
char wCol;
char wCol2;
char color;
char rules;
std::string wColor;
int counter = 0;
playG = 'Y';

//prompts user to read rules or not
cout << "Would you like to see how to play?Y/N " << flush;
cin >> rules;
if ((rules != 'y' || rules != 'Y') || (rules != 'n' || rules != 'N'))
{
while ((rules != 'y' || rules != 'Y') || (rules != 'n' || rules != 'N'))
{
cout << "Please enter Y or N: " << endl;
cin >> rules;
}
}
[code]
Last edited on
while ((rules != 'y' || rules != 'Y') || (rules != 'n' || rules != 'N'))

when is this false? Put any value into rules, what do you get?
hint: true or false is true. true or true is true. Only false or false is false. Can you ever have all 4 conditions false at once?
Last edited on
Topic archived. No new replies allowed.