Use arow keys in your c program

Here is a simple code that you can use in your c program in order to use the arrow keys, enter key or any other key in your program. This is very useful since users will be able to interact with your program output naturally with arrow or enter keys.

int get_scancode()
{
union REGS inregs, outregs ;

while( !kbhit( ) ) /* while the keyboard is inactive */
; /* do nothing */
inregs.h.ah = 0 ;
int86(22, &inregs, &outregs) ;
return ( outregs.h.ah ) ;
}

Just call the above function when you need the user to press a certain key. The function will return the scancode of the key pressed. Compare the returned value with the scancode of the key you want and do the corresponding work.
Usual scan codes:

up arrowkey 72
downarrow key 80
leftarrow key 75
rightarrow key 77

enter key 28

Here is an program[Linked List] with arrow and enter keys. The output may get distorted on your computer. In that case try directly compiling and running the source code.