/ Published in: C++
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
#include <stdio.h>
#include <limits.h>
// Convert a char to a binary string representation of that char value
char* chartobin ( unsigned char c )
{
static char bin[CHAR_BIT + 1] = { 0 };
int i;
for ( i = CHAR_BIT - 1; i >= 0; i-- )
{
bin[i] = (c % 2) + '0';
c /= 2;
}
return bin;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                