I can print with printf as a hex or octal number. Is there a format tag to print as binary, or arbitrary base?
I am running gcc.
printf(\"%d %x %o
The following recursive function might be useful:
void bin(int n) { /* Step 1 */ if (n > 1) bin(n/2); /* Step 2 */ printf("%d", n % 2); }