This function is much more economical in memory that the function "printf" (just to make a conversion)
Code:
/************************************************************************
Function: Int2Str(char *pStr, unsigned int value, int charCount)
Overview: Converts integer value to string to be displayed in the
edit boxes that displays the RGB values.
Input: pStr - pointer to the string holder of the value to be displayed
value - the integer value that will be converted.
charCount - the number of characters that was converted.
Output: none
************************************************************************/
void Int2Str(char *pStr, unsigned int value, int charCount)
{
// this implements sprintf(strVal, "%d", temp); faster
// note that this is just for values >= 0, while sprintf covers negative values.
// this also does not check if the pStr pointer points to a valid allocated space.
// caller should make sure it is allocated.
// point to the end of the array
pStr = pStr + (charCount - 1);
// convert the value to string starting from the ones, then tens, then hundreds etc...
do
{
*pStr-- = (value % 10) + '0';
value /= 10;
} while(charCount--);
}