write a program that uses a two dimensional of 256*8 to store 8 bit binary representations of each of the characters of ASCII character set.
#include <stdio.h>
int main()
{
int i, j;
char data[256][8];
for(i = 0; i < 256; ++i)
{
char tmp = (char) i;
for(j = 0; j < 8; ++j)
{
data[i][j] = tmp & 0x01 ? '1' : '0';
tmp >>= 1;
}
}
for(i = 0; i <= 255; ++i)
{
printf("%d\t%c\t", i, i);
for(j = 7; j >= 0; --j)
{
printf("%c", data[i][j]);
}
printf("\n");
}
return 0;
}
Comments
Leave a comment