fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void BinFormat(char character, char *text) {
  5. text[8] = '\0';
  6. for (int i = 7; i >= 0; i--) text[i] = ((character >> i) & 1) + '0';
  7. }
  8.  
  9. int main(void) {
  10. char *text = malloc(9);
  11. BinFormat('A', text);
  12. printf("%s\n", text);
  13. BinFormat('B', text);
  14. printf("%s\n", text);
  15. BinFormat('C', text);
  16. printf("%s\n", text);
  17. }
  18.  
  19. //https://pt.stackoverflow.com/q/286742/101
Success #stdin #stdout 0s 4364KB
stdin
Standard input is empty
stdout
10000010
01000010
11000010