top of page
ASCII Conversion
An ASCII character is a code for representing letters with numbers. These may be hexadecimal numbers, binary numbers, octal numbers, and soforth. Generally coders will be working with decimal numbers, the normal numbering system we use daily. Each letter in the alphabet along with some symbols and has an assigned decimal number to it.
The standard list of printable ASCII characters range from the decimal value 32 to 126.

So, if a character is really just a decimal number we can print characters from these integer values. Try making an integer equal to 65 then printing it using the %c conversion character with printf.
Example:
Output:


As expected we get the character value equal to the value we inserted as an integer.
We can also set an integer value equal to a character and it will automatically set the integer equal to the decimal equivalent of the character.
Example:
Output:


While it may not be necessary to remember the entire ASCII table it is helpful to remember that capital 'A' starts at decimal number 65 and lowercase 'a' starts at decimal equivalent 97.
PS: Here's a really simple little script to generate the printable contents of the ASCII table.

bottom of page