I'm trying to make a program that reads when an arrow key is pressed using getch() but it doesnt work.I use the ASCII values of the arrow keys to test if an arrow key has been pressed in the switch.

Whats wrong and how can I make that a program notes when an arrow key has been pressed?



#include <stdio.h>
#include <stdlib.h>

main(void)
{
int x=0,y=0,c;

do{
system("cls");
printf("x=%d,y=%d",x,y);
c=getch();

switch(c){
case 24:
y+=1;
break;
case 25:
y-=1;
break;
case 26:
x+=1;
break;
case 27:
x-=1;
break;
}
}while(c!='q');


return 0;
}