You're only reading one character from cin
per iteration of the while loop. This means your program is going to process each character individually until it has cleared the cin
buffer.
The simple fix is to add fflush(stdin)
inside and at the end of your while loop. This way, you're only reading the first character in the cin
buffer and discarding the rest.
Some may tell you to read the entirety of cin
into a std::string
, but for your case you'll be able to get away with discarding every character but the first one.
In case you didn't read, here is your code snippet:
do{
cout << "Would you like to play (Y/N): ";
cin >> gameSelect;
if(gameSelect == 'Y'){
}
else if(gameSelect == 'N'){
cout << "Thank You For Playing!\n";
}
else{
cout << "Invalid Input, Try Again (Y/N)\n";
}
fflush(stdin); // discard all remaining characters in cin
}while(gameSelect != 'N');