Programming: Where can I find an ASCII Table?

In summary, to decode a binary message into ASCII characters in C, you do not need a lookup table. Simply convert the binary numbers to integers and then cast them to characters. Each 8-bit chunk of the message represents one ASCII character.
  • #1
carlodelmundo
133
0

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!
 
Physics news on Phys.org
  • #2
I am not sure what your problem is. If you convert binary number to int and to char, it is already in ASCII.
 
  • #3
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
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 to Programming: Where can I find an ASCII Table?

1. What is an ASCII table?

An ASCII table is a chart that displays the numerical codes for characters in the ASCII (American Standard Code for Information Interchange) character set. It is used to represent and encode text in computers and other devices.

2. Why is an ASCII table important in programming?

ASCII is the most commonly used character encoding system in computer programming. It allows programmers to represent and manipulate text characters in a standardized way, making it easier to communicate and transfer data across different platforms and devices.

3. Where can I find an ASCII table online?

There are many websites that offer ASCII tables for free, such as ASCII Table.com, RapidTables, and TechOnTheNet. You can also find ASCII tables in programming textbooks and reference manuals.

4. How do I read an ASCII table?

An ASCII table is organized into columns and rows, with the first column representing the decimal number of each character code. The remaining columns represent the hexadecimal and binary values of the character. To find the ASCII code for a specific character, locate the row and column corresponding to that character.

5. Can I use an ASCII table to convert characters to their corresponding ASCII codes?

Yes, an ASCII table can be used to convert characters to their corresponding ASCII codes. Simply find the character in the table and look at the decimal value in the first column. This decimal value is the ASCII code for that character.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Programming and Computer Science
2
Replies
57
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
13
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
Back
Top