This C++ code will convert the typing keystrokes from keyboard into it’s ASCII code(HEX).
1: #include<stdio.h>2: #include<conio.h>3:4: char HEXST(char a){5: int rem,no=int(a),i=0;6: char tmp,string[2];7:8: while(no>0){
9: rem=no%16;10: no=(no/16);11:12: switch(rem){
13: case 10:
14: tmp='A';15: break;
16: case 11:
17: tmp='B';18: break;
19: case 12:
20: tmp='C';21: break;
22: case 13:
23: tmp='D';24: break;
25: case 14:
26: tmp='E';27: break;
28: case 15:
29: tmp='F';30: break;
31: default:
32: tmp=rem;33: }34: string[i]=tmp;
35: i++;36: }37: for(int y=1;y>=0;y--){38: if(string[y]<65||string[y]>122)39: printf("%d",string[y]);40: else
41: printf("%c",string[y]);42: }43:44: }45: void HEXS()
46: {47:48: char typed;
49: printf("Enter Words and Corresponding Hex will be displayed\n=======================================\n\n\nPress Esc twice to quit");
50: while(typed!=27){
51: typed=getch();52: printf("\n%c\t",typed);
53: HEXST(typed);54: }55: getch();56: }57:58: void main()
59: {60: HEXS();61: }62:
Comments
Post a Comment