ASCII Table Reference


Learn it

Presented by Higher Edge Software, LLC

C ASCII Conversions

Quick C code examples on how to convert ascii character values to decimal, binary, hexidecimal, and octal numbers.

The function sprintf will return the string represenation of any number of arguments passed to it.

Character to Decimal


char charString = 'A';
int charDecimalValue = (int)charString;

The variable charDecimalValue will return the number: 65.

Character to Binary


Coming soon...

Character to Hexidecimal


#include <stdio.h>
char hexString[20];
char charString = 'A';
int charDecimalValue = (int)charString;
sprintf (hexString, "%x", charDecimalValue);

The variable hexString will return the string: 41.

Character to Octal


#include <stdio.h>
char octString[20];
char charString = 'A';
int charDecimalValue = (int)charString;
sprintf (octString, "%o", charDecimalValue);

The variable octString will return the string: 101.


Higher Edge Software, LLC