Last active
May 23, 2018 22:08
-
-
Save EncodeTheCode/f0d9918844558f87c0030eb75a6f024a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <stdio.h> | |
using namespace std; | |
char const hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B','C','D','E','F'}; | |
int main(){ | |
// Testing char: printf("%c",13); | |
char c; | |
c=cin.get(); | |
// else if(c=='\n') { cout << "Enter pressed!"; } | |
if(c==10) { cout << "The enter key was pressed!\n"; /* Trap Enter key. 0x10, \x10 */ } | |
else if(c==13) { cout << "Carriage return performed!\n"; } | |
else if(c==0x20) { cout << "Space pressed!\n"; /* Trap Space key. */ } | |
else if(c==0x41) { cout << "A pressed!\n"; /* Trap A key. */ } | |
else if(c==0x42) { cout << "B pressed!\n"; /* Trap B key. */ } | |
else if(c==0x43) { cout << "C pressed!\n"; /* Trap C key. */ } | |
else if(c==0x44) { cout << "D pressed!\n"; /* Trap D key. */ } | |
else { cout << "Something pressed...\n"; /* Trap any key besides the ones from the if statements above. */ } | |
if(c!=10 || c==13) { cout << "Converted character to HEX: " << std::hex << int(c) << ".\r\n"; /* Convert character to HEX. */ } | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment