I am running in to some strange behavior with calling functions with parameters that contain getch().
Take the following code for example:
_Bool IsKeyDown(char c)
{
if(!kbhit())
return 0;
char ch1 = getch();
printf("%c\n", c);
return 0;
}
/*
*
*/
int main(int argc, char** argv) {
while(1)
{
IsKeyDown('a');
IsKeyDown('b');
Sleep(100);
}
return (EXIT_SUCCESS);
}
When a key is pressed with this code, no matter what, it will always print 'a', which is the parameter of the first function. The issue is, 'a' is not the parameter of the second function being called, yet 'a' is still printed instead of 'b'. Why is this occuring?