int itoa(int n, char* s, int msize)
{
int i = 0;
int digit = 0;
if ( n < 0 )
{
s[0] = '-';
n *= -1;
i++;
}
while (n > 0)
{
digit=n%10;
n/=10;
s[i]= digit + '0';
i++;
}
s[i]='\0';
//reverse(s);
return 0;
}
All you need now is some error check on msize overrun and reverse, also might need to adjust placing of sign lines in the sequence. Too trivial for me so make it an exercise for OP. Also need to cater for zero, another exercise for OP :)