Monday, 9 May 2016

C++ Program of detecting a keypress and ASCII code

  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4. int main()
  5. {
  6.     char key_press;
  7.     int ascii_value;
  8.     cout<<"\n\t\t\tPress Any Key To Check  Its ASCIValue\n\n\t\t\tPress ESC to EXIT\n\n\n";
  9.     while(1)
  10.     {
  11.     key_press=getch();
  12.     ascii_value=key_press;
  13.     if(ascii_value==27) // For ESC
  14.      break;
  15.    cout<<"\t\t\tKEY Pressed-> \" "<<key_press<<" \" Ascii Value =  "<<ascii_value<<"\n\n";
  16.     }
  17.     return 0;
  18. }
Share:

0 comments:

Post a Comment