Scan codes of arrow keys using C ??

#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<dos.h> getkey(); void main() { clrscr(); int x; /* to save the value of scan code returned by getkey()*/ x=getkey(); printf("%d",&x); getch(); } getkey() { union REGS i,o; while(!kbhit()) ; ... show more #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
getkey();
void main()
{
clrscr();
int x; /* to save the value of scan code returned by getkey()*/
x=getkey();
printf("%d",&x);
getch();
}

getkey()
{
union REGS i,o;
while(!kbhit())
;
i.h.ah=0;
int86(22,&i,&o);
return(o.h.ah);
}


Every time I run this code and press any key(even arrow keys) i get a value -12 i.e. minus 12.
i know that for arrow keys scan codes are 72,80,75,77 but i the function getkey is of no help .

Please tell me whats wrong with getkey function.
1 answer 1