char * getNumberString(unsigned long * pDigitSpan, long number) { /* * get the number of digits in the number you''re converting */ unsigned long digitSpan = 0;

long tempNum = number;

while (tempNum > 0) { tempNum /= 10; digitSpan++; }

/* * actually build up the string of number */ char * numberString = new char[digitSpan];

tempNum = number;

for (unsigned long i = digitSpan; i > 0; i--) { //see note below about this line numberString[i-1] = tempNum % 10;

tempNum /= 10; }

//i know you could probably incriment the *pDigitSpan //instead of doing this assignment down here //but i ran into some wierd problems doing something similar //in another program so... *pDigitSpan = digitSpan;

return numberString;}

this also gives you the digit length of the number.

i think you need to convert tempNum % 10 from a single digit number into a char. i don''t remember exactly how to do that but i think it might be:

numberString[i-1] = ((char) tempNum % 10) - (char) 0;

damn, been way too long since i converted numerals into chars...

anyway, you can also use this function to convert to a binary number if you change the 10 to a 2 in all the % and /= statements. or even better would be to generecize the function by adding a passed int of the base number system you want to convert to. then use that instead of /= 10; (i.e. /= base

whatever, i know this function works for converting to binary. cause i wrote it for that purpose cept used a return type of bool * to conserve memory space.