-
KBHIT isn't working
The user is asked whether he/she would like to continue with the program.
Code:
cin.ignore(); //ignores the previous input so it cannot interfere with this section of code
if( kbhit() ) { //if the keyboard is hit
KeyCode = getch(); //KeyCode(declared as an int) equals getchar
if(KeyCode != 89) //if the GetChar is not 'Y' (or 89 in Decimal)
EnteringData = false; //
}
for some reason that code does not seem to work. Even if the user does not hit Y the program continues.
Oh yeah I almost forgot to mention you can look up the characters' decimal values at www.asciitable.com
-
ignore() is acting on the second input also. This member function is usually used as a means to ignore certain characters on an input. I'm not sure of this, but I can only assume that ignore with no arguments (it usually accepts 2) will ignore every character on the input indefinitely. Hence the behavior on your application
Do cin.ignore(256,'\n')... that way, ignore will cease to affect cin as soon as the previous input will either reach 256 ignored characters or you hit the return key.
Or
Just remove the line altogether. I don't see why any previous cin will affect kbhit()