Sunday, 23 December 2012

Determine ASCII value for a inputted key/character

/* compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/
/* A program to determine ASCII value for a input key. */

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

int getkey(void);

void main()
{
 int x;
 clrscr();
 printf("Enter any Key: ");
 x=getkey();
 printf("\nASCII VALUE  OF ENTERED KEY IS: %d",x);
 getch();
}

int getkey(void)
{
 int key, lo, hi;
 key = bioskey(0);
 lo  = key & 0X00FF;
 hi  = (key & 0XFF00) >> 8;
 return((lo == 0) ? hi + 256 : lo);
}

 /*=========================30Nov.,2011=============================*/

No comments:

Post a Comment

You are welcome, your comment helps me to make this blog more better.