Search This Blog

Loading...

Write a program to read a character from KeyBoard with echo using Interrupt 21h

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

 constchar Getche( );

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

    printf("Press ANY key : ");
    key=Getche( );
    printf("\nASCII Code for Input Key = %d",key);

    getch( );
    return 0;
 }


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

    InReg.h.ah=0x01;

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

    return OutReg.h.al;
 }

No comments:

Post a Comment