fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. void print_bin(char c) {
  5. for (int i = 128; i != 0; i >>= 1)
  6. printf("%c", c & i ? '1' : '0');
  7. puts("");
  8. }
  9.  
  10. int main() {
  11. const char* string = "Hello World";
  12.  
  13. for (size_t i = 0; i < strlen(string); i++) {
  14. printf("%c = %x (%d) = ", string[i], string[i], string[i]);
  15. print_bin(string[i]);
  16. }
  17. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
H = 48 (72) = 01001000
e = 65 (101) = 01100101
l = 6c (108) = 01101100
l = 6c (108) = 01101100
o = 6f (111) = 01101111
  = 20 (32) = 00100000
W = 57 (87) = 01010111
o = 6f (111) = 01101111
r = 72 (114) = 01110010
l = 6c (108) = 01101100
d = 64 (100) = 01100100