Search This Blog

Loading...

Program to read a character from KeyBoard using Interrupt 21h

 # include <stdio.h>
 # include <conio.h>
 # include   <dos.h>

 constchar Getch( );

 int main( )
 {
    int key=0;
    clrscr( );

    printf(" Press ANY key : ");
    key=Getch( );

    printf("\n\n ASCII Code for Input Key = %d",key);

    getch( );
    return 0;
 }

 /* Getch( ) */

 constchar Getch( )
 {
    union REGS InReg;
    union REGS OutReg;

    InReg.h.ah=0x8;

    int86(0x21,&InReg,&OutReg);

    return OutReg.h.al;
 }

No comments:

Post a Comment