Question 1: The C code
#include "stdio.h"
int main(int argc, char **argv)
{
typedef struct {
char ch ;
unsigned int theByte ;
} table_entry ;
table_entry code_table[] =
#include "table.h"
;
printf("Code table contents:\n");
for(int i = 0 ; i < (sizeof(code_table) / sizeof(table_entry)); i++) {
printf("%c 0x%2.2X %c\n",
code_table[i].ch,
code_table[i].theByte,
(char)(code_table[i].theByte) );
}
int inputChar ;
while( EOF != ( inputChar = getchar() ) ) {
if( (unsigned char)inputChar == ' ') {
printf(" ") ;
} else {
printf("%c", code_table[ ( (char)inputChar - 'A' ) ].theByte ) ;
}
}
printf("\n") ;
}