Skip to content

Instantly share code, notes, and snippets.

@Prince781
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save Prince781/11023503 to your computer and use it in GitHub Desktop.

Select an option

Save Prince781/11023503 to your computer and use it in GitHub Desktop.
Prints out binary form of whatever is given.
#include <stdio.h>
void printb(unsigned long v) {
if (v>>1 > 0) printb(v>>1);
putchar((v&1) + '0');
}
int main(int argc, char *argv[]) {
if (argc > 1)
printb(atol(argv[1]));
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment