fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. const int maxdigits = 20; /* max number of base 6 digits */
  8. int num=123456789, rem = 0;
  9. int tempnum = abs(num);
  10. int lastpos = maxdigits;
  11.  
  12. /* initialize array, and initialize array to spaces */
  13. char res[maxdigits + 1];
  14. memset(res, ' ', maxdigits);
  15.  
  16. /* null terminate */
  17. res[maxdigits] = 0;
  18.  
  19. while(tempnum != 0)
  20. {
  21. rem = tempnum % 6;
  22. res[lastpos--] = rem + '0'; /* set this element to the character digit */
  23. tempnum /= 6;
  24. }
  25. printf("%s%s", (num<0?)"-":"", res + lastpos + 1); /* print starting from the last digit added */
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:9:18: warning: implicitly declaring library function 'abs' with type 'int (int)' [-Wimplicit-function-declaration]
   int tempnum = abs(num);
                 ^
prog.c:9:18: note: include the header <stdlib.h> or explicitly provide a declaration for 'abs'
prog.c:25:26: error: expected expression
   printf("%s%s", (num<0?)"-":"", res + lastpos + 1); /* print starting from the last digit added */
                         ^
prog.c:25:26: error: expected ':'
   printf("%s%s", (num<0?)"-":"", res + lastpos + 1); /* print starting from the last digit added */
                         ^
                         : 
prog.c:25:25: note: to match this '?'
   printf("%s%s", (num<0?)"-":"", res + lastpos + 1); /* print starting from the last digit added */
                        ^
prog.c:25:26: error: expected expression
   printf("%s%s", (num<0?)"-":"", res + lastpos + 1); /* print starting from the last digit added */
                         ^
1 warning and 3 errors generated.
stdout
Standard output is empty