Using getch and Beep, with some other stuff, im trying to make a program that plays music based on your keypresses. however, the console is spammed with tons of keys, even when i dont press anything. here is my code:
Code:
i cant see why the while loop isnt holding getch(); even if getch should wait for user input. any help?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int FGetKey();
int Input;
int GetKey;
int Atmp;
int Btmp;
int Ctmp;
int main()
{
while (GetKey != 56)
{
FGetKey();
printf("Key: %d %x %c", GetKey, GetKey, GetKey);
Atmp = GetKey * 100;
Beep(Atmp, 200);
}
return 0;
}
int FGetKey()
{
GetKey = 0;
while (GetKey != 0)
{
GetKey = getch();
}
}
i cant see why the while loop isnt holding getch(); even if getch should wait for user input. any help?