fork(10) download
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. char * convert(int dec, char *output) {
  6. output[4] = '\0';
  7. output[3] = (dec & 1) + '0';
  8. output[2] = ((dec >> 1) & 1) + '0';
  9. output[1] = ((dec >> 2) & 1) + '0';
  10. output[0] = ((dec >> 3) & 1) + '0';
  11. return output;
  12. }
  13.  
  14. int main(void) {
  15.  
  16. char binary[5];
  17. convert(1, binary);
  18. printf("%s", binary);
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 4528KB
stdin
Standard input is empty
stdout
0001