• Support PF! Buy your school textbooks, materials and every day products Here!

Programming: Where can I find an ASCII Table?

  • #1

Homework Statement



I am given the binary equivalent of ASCII codes and I am asked to decode a particular binary message (ASCII binary to actual ASCII character).

I am required to write it in C. Where can I get a text file of the ASCII code so I may create a look up table?

I googled, but I could not find a text file. And manually copying and pasting it into a document is not fun.

Thanks!
 

Answers and Replies

  • #2
Borek
Mentor
28,326
2,713
I am not sure what your problem is. If you convert binary number to int and to char, it is already in ASCII.
 
  • #3
33,159
4,845
You don't need a lookup table. Since what you start with already contains the ASCII codes for the characters in the message, all you need to do is separate the message into 8-bit chunks (bytes) and then print each one.

This code displays the character 'A'.
printf("%c", 0x41);

For example, if the ASCII string contains 43, 41, 54 (each in hex), printing them would result in C A T.
 
  • #4
You mean if I have the following txt file:

Code:
01001001 01100110 00100000 01111001 01101111 01110101 00100000 01110111 
01100001 01101110 01110100 00100000 01101101 01101111 01110010 01100101 
00100000 01100101 01100110 01100110 01100101 01100011 01110100 01101001 
01110110 01100101 00100000 01110000 01110010 01101111 01100111 01110010
I am able to decode the messages just by casting them to chars?

EDIT: I see. I did the following:

Code:
printf("%c", 01000111);
It seems to have done the trick. Thanks
 
  • #5
Borek
Mentor
28,326
2,713
Not "just by casting". Your first number - 01001001 - is in fact 73 (dec). Convert it to a number and cast this number to char - and you will find it is "I".
 

Related Threads for: Programming: Where can I find an ASCII Table?

Replies
8
Views
615
Replies
18
Views
8K
  • Last Post
Replies
1
Views
905
  • Last Post
Replies
11
Views
4K
Replies
14
Views
5K
Replies
4
Views
2K
Replies
2
Views
1K
Replies
0
Views
7K
Top