Here ... help
void itoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0)
n = -n;
i = 0;
do {
s[i++] = n % 10 + '0';
} while ((n /= 10) > 0);
if (sign < 0)
s[i++] = '-';
s[i] = '\0';
reverse(s);
}
You must adapt it to your needs (note that this has 2 arguments, not 3) Also note that the inverse function is also in the wikipedia link.
Also, here are some other cases (but not for base 2)
This function is not defined in ANSI-C and is not part of C ++, but is supported by some compilers.
sprintf:
sprintf(str,"%d",value) .
sprintf(str,"%x",value) .
sprintf(str,"%o",value) .