pick the code you want from this program or go to asciitable.com
Code:
#include <iostream.h>
#define NUL 0
#define BEL 7
#define BS 8
#define TAB 9
#define LF 10
#define CR 13
#define SUB 26
#define SPC 32
#define BLK 255
#define ROWS 9
#define COLUMNS 5
int main(void)
{
const char ASCII_NAMES[ROWS][COLUMNS]={{"NUL \0"}, {"BEL \0"}, {"BS \0"}, {"TAB \0"},
{"LF \0"}, {"CR \0"}, {"SUB \0"}, {"SPC \0"},
{"BLK \0"}
};
enum AsciiSubscript{MSG_NUL, MSG_BEL, MSG_BS, MSG_TAB, MSG_LF, MSG_CR, MSG_SUB,
MSG_SPC, MSG_BLK};
const unsigned HEX_BASE = 16;
unsigned AsciiNum = 0;
printf(" ");
for(unsigned i = 0; i <= HEX_BASE - 1; i++)
printf("%02X ", i);
printf("\n");
for(unsigned HexNum = 0; HexNum <= HEX_BASE - 1; HexNum++)
{
printf("%X0 ", HexNum);
for(int Line=0; Line <= HEX_BASE - 1; Line++)
{
switch(AsciiNum)
{
case NUL : printf("%s", ASCII_NAMES[MSG_NUL]); break;
case BEL : printf("%s", ASCII_NAMES[MSG_BEL]); break;
case BS : printf("%s", ASCII_NAMES[MSG_BS]); break;
case TAB : printf("%s", ASCII_NAMES[MSG_TAB]); break;
case LF : printf("%s", ASCII_NAMES[MSG_LF]); break;
case CR : printf("%s", ASCII_NAMES[MSG_CR]); break;
case SUB : printf("%s", ASCII_NAMES[MSG_SUB]); break;
case SPC : printf("%s", ASCII_NAMES[MSG_SPC]); break;
case BLK : printf("%s", ASCII_NAMES[MSG_BLK]); break;
default : printf("%c ", (char)AsciiNum);
}
AsciiNum++;
if(Line == HEX_BASE -1)
printf("\n");
}
}
getchar();
return 0;
}