fork download
  1. #include <stdio.h>
  2.  
  3. #define maxdigits 65
  4. char buffer[maxdigits];
  5.  
  6. /* fill in from rhd */
  7. void PrintBinary(int value) {
  8. char tempbuffer[maxdigits];
  9. char c;
  10. int index=maxdigits-2;
  11. tempbuffer[maxdigits-1]='\0';
  12. while (value >0) {
  13. tempbuffer[index--]= value & 1?'1':'0';
  14. value = value >> 1;
  15. }
  16. tempbuffer[index]='%';
  17. printf("%sb\n\r",&tempbuffer[index]);
  18. }
  19.  
  20.  
  21. int main(int argc, char* argv[])
  22. {
  23. PrintBinary(10);
  24. PrintBinary(8);
  25. PrintBinary(32765);
  26. return 0;
  27. }
Success #stdin #stdout 0s 1832KB
stdin
Standard input is empty
stdout
%1010b

%1000b

%111111111111101b