Hi there,I'm a novice programmer taking an online C course. ive come up against a problem in an exercise that Im hoping to get help with.
Im writing a function to convert a string of ascii chars to binary.
So far what I have is this
void asciiBinary (void)
char* bb = "3D";
for (i =0;i < strlen(bb); i++)
char x =bb[i];
for(y = 0; y < sizeof(char) * 8; y++)
printf("%c ", ( x & (1 << y) ) ? '1' : '0' );
I've heavily adapted this from code used in another binary function.
Now this is cool, it almost works, but it prints out the binary numbers in reverse
ie 11001100 00100010
not 00110011 01000100
I think the fault lies in the bitwise operator...
Any advice on how to fix this?