Hi, I hope someone here can lead me in the right direction.
I use MS Visual Studio 2008 and Eclipse for editing and compiling my code.
I go a problem with following code:
1 2 3 4 5 6 7 8 9 10
|
while(getGateType = _getch()) //validating the users input
{
if(getGateType > '0' && getGateType < '7')
break;
coutAlignError(0,60,22,"You did not select one of the available gates!"); //if the user input isn't valid we notify with an onscreen message
}
coutAlign(0,60,22,""); //if there is an error message it gets removed
GateType = (int)getGateType - '0'; //converting char to int with the same numeric value
|
The problem as you probably already can see from the title, is that my code doesn't stop the F1 - F12 keys, with the result that I get an unvalid input send down to the rest of my code.
Thing that happens is, it checks the first byte, but not the complete key input at once.
So if that first byte is between 1 and 6 it goes through together with the remaining 2-3 bytes..
I tried different approaches, like declaring a string, checking its length etc. but so far nothing seemed to work out for me.
Is there a way to limit the input stream in such way that my program only accepts the very first byte in every keystroke and cuts of the rest?
If some might need to look over the complete code to have a better overview, it can be found on OpenSVN;
https://opensvn.csie.org/traccgi/cpp_projects/browser/Logical_Gates/src