Well, without relying on a toolbox routine, I guess my initial thought is that your name is base 10, so in order to isolate each value, you divide by 10. This is purely brute force, I know this could be done more elegantly. But it's a start.
The below deals with _positive_ numbers only. We'd have to keep track of the sign value, otherwise (not hard, just left as an exercise for the reader (grin)).
Code:
char asciiVals[] = {'0','1','2','3','4','5','6','7','8','9'};
char asciiEquivalent[12]; /* big enough for any reasonable number */
void num2str(int); /* prototype */
void num2str(int a)
{
int scratch;
int index;
int len;
asciiEquivalent[0] = 0x00; /* init string */
/* this would also be where we would keep track of sign value */
if(!a)
{
asciiEquivalent[0] = '0'; /* it's a zero, bail early */
asciiEquivalent[1] = 0x00;
return;
};
len = 0;
scratch = a /* determine # of digits */
while(scratch)
{
scratch /= 10;
len++;
};
asciiEquivalent[len] = 0x00; put terminator byte into string */
len--;
scratch = a; /* make a copy of original value */
while(scratch) /* divide and conquer until zero */
{
/* you could modulo the next, but this shows the work */
scratch /= 10; /* knock of least significant digit */
index = (a-scratch); /* determine what got knocked off */
asciiEquivalent[len] = asciiVals[index]; /* build the string */
len--;
};
}
enjoy.