It's kind of a silly question. Do what you want. The %o and %x formats for printf are defined to work only with unsigned integers so they interpret the representation of the signed value as an unsigned value.
BTW, the correct answer for a negative signed integer 2's complement representation depends on the number of bits of the variable. For 16 bits, -10 is fff6, but for 32 bits (which is what your system uses) it is fffffff6.
BTW2, there is no such thing as writef.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
void print_unsigned(unsigned n, unsigned b) // b in [2, 36]
{
const char *a = "0123456789abcdefghijklmnopqrstuvwxyz";
if (n >= b) print_unsigned(n / b, b);
putchar(a[n % b]);
}
void print_signed(int n, int b) // b in [2, 36]
{
if (n < 0) { putchar('-'); n = -n; }
print_unsigned(n, b);
}
int main()
{
char line[256];
while (printf(">>> "), fgets(line, sizeof line, stdin) != NULL)
{
int n = 0;
if (strcmp(line, "min\n") == 0) n = INT_MIN;
else if (strcmp(line, "min+1\n") == 0) n = INT_MIN + 1;
else if (strcmp(line, "max\n") == 0) n = INT_MAX;
else if (strcmp(line, "-max\n") == 0) n = -INT_MAX;
else
n = atoi(line);
printf("d: %d\n", n);
for (int b = 2; b <= 36; ++b)
{
printf("%2d: ", b);
print_signed(n, b);
putchar('\n');
}
}
putchar('\n');
return 0;
}