I have a program where a certain sound is played corresponding to a key pressed on the keyboard. But every time I press a key, I have to press Enter for the sound to be played. What I actually want to do is to press the key without having to press Enter and a sound should be played. How can I do this?
I'm using Windows 10. Here is my code:
while(1)
{
cin>>button;
switch (button)
{
case 'q':
PlaySound( TEXT("C:\\Users\\Gumm\\Downloads\\real sound of notes\\ardha chapu.wav"),NULL,SND_SYNC );
break;
case 'w':
PlaySound( TEXT("C:\\Users\\Gumm\\Downloads\\real sound of notes\\chapu"),NULL,SND_SYNC );
break;
case 'e':
PlaySound( TEXT("C:\\Users\\Gumm\\Downloads\\real sound of notes\\dheem"),NULL,SND_SYNC );
break;
default:
printf("No sound");
}
}