fork(1) download
  1. #include <stdio.h>
  2.  
  3. union num
  4. {
  5. int f;
  6. char c[4];
  7. };
  8.  
  9. void printBinary(union num u)
  10. {
  11. int i,t,j;
  12.  
  13. for(i=sizeof(u)-1; i>=0; i--)
  14. {
  15. for(j=0,t=128; j<8; j++,t>>=1)
  16. printf("%d",(u.c[i]&t)?1:0);
  17. printf(" ");
  18. }
  19. }
  20.  
  21. int main()
  22. {
  23. union num n;
  24. n.f=10;
  25. printBinary(n);
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 1676KB
stdin
Standard input is empty
stdout
00000000 00000000 00000000 00001010