C Programming Tutorial 24 -ASCII

Don’t forget to read the last blog on Format Characters for Float and Double! Are you new here? Start at the beginning, Intro to C!

We are now going to begin our discussion of the char data type!

Now, char is short for character. A character is any number, letter, or symbol that can be used on a computer. That’s not all of the characters, though. There are actually some characters that do certain things. For example, there is a tab character, there is a newline character, there is a space character, there is even a null character.

A null is the absence of something. So yes, the null character is literally a character that is nothing. But it is still a very important character as we will see later. There are many different types of characters.

How do we know what is a character or not? Well, there is a collection of allowed characters. This is known as a character set. The character set that I am going to be teaching you about today is called ASCII.


Now, before we dive into ASCII, I wanted to discuss something called binary. When I say binary, you should automatically think of something that is in two states. Binary is the most fundamental way that the computer stores information.

Imagine that we have a number, and this number has only two states. The possible values we could use are 0 and 1. This is called a bit. A single bit can be used to represent anything that is in two states, such as on or off, high or low, hot or cold, she loves me or she loves me not, etc.

Well, computers use binary to store information. If we have a bunch of zeros or ones we can start to build more complex information. We will often have groups of bits. One of the most common sized group of bits is called a byte, which is 8 bits. For example, we could have 01000001.


Now, back to ASCII. ASCII will use this to represent 1 character. So 010000001 represents the character A.

Now, the standard ASCII character set is only going to use 7 of the 8 bits. Sometimes it will use 8 and this is known as extended ASCII. With 7 available bits we can have a total of 128 possible characters. This includes the entire English alphabet (capital and lower case), all numbers, a bunch of symbols, and some special characters such as the newline character.

Now, how does the computer know that 01000001 is A? This has to do with how the binary is interpreted. That’s because this binary number could just as easily be a way to represent some number. In fact, if this was considered an integer, this number is 65.

So you can directly convert between binary and integer data. Every ASCII character can be represented as a number. In the next videos we will be using the char data type and learning more about converting between char and int.

Are you ready to learn more? Learn about the Char Data Type in the next blog!

Leave a Reply

Your email address will not be published. Required fields are marked *