I am trying to print the string "Hello"
in binary.
I get it to work, however, I would like it to print without the padded at the end
so
01001000 01100101 01101100 01101100 01101111
instead of
01001000 01100101 01101100 01101100 01101111 00000000
Here is my code:
char t[] = "Hello";
for (int j = 0; j < sizeof(t); j++)
{
unsigned char c = t[j];
for (int i = 7; i >= 0; i--) {
printf("%d", (c >> i) & 1 ? 1 : 0);
}
printf(" ");
}