GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


Binary Byte to ASCII String by DELTRON
// Binary Byte to ASCII String - Delt 1/19/05

#include <stdio.h>

void main(void)
{
    char b[9];

    char c = (char)0xAA;

    b[0]='1'-!(c&128);
    b[1]='1'-!(c&64);
    b[2]='1'-!(c&32);
    b[3]='1'-!(c&16);
    b[4]='1'-!(c&8);
    b[5]='1'-!(c&4);
    b[6]='1'-!(c&2);
    b[7]='1'-!(c&1);
    b[8]=0;

    printf("%X in HEX is %s in BINARY\n\n",(unsigned char)c,b);

}