fork(16) download
  1. #include <stdio.h>
  2.  
  3. void printCharAsBinary(char c) {
  4. int i;
  5. for(i = 0; i < 8; i++){
  6. printf("%d", (c >> i) & 0x1);
  7. }
  8. }
  9.  
  10. void printStringAsBinary(char* s){
  11. for(; *s; s++){
  12. printCharAsBinary(*s);
  13. printf(" ");
  14. }
  15. printf("\n");
  16. }
  17.  
  18. int main(void) {
  19. char s1[] = "Foo";
  20.  
  21. printStringAsBinary(s1);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
01100010 11110110 11110110