There are a few things wrong with your logic:
- The variable
is used by never initialized. I would guess it should be initialized to zero and then incremented in the while loop with the ++ operator.
- Also in the while loop,
should probably be set with the /= operator.
- Another thing is the
pointer appears to be set using the comparison operator instead of the assignment operator which is a single equals sign.
Here is what your logic looks like with these changes :
void ToString( char* str, int number )
int size = 0;
int temp = number;
while( temp != 0 )
temp /= 10;
for( int i = size - 1; i >= 0; --i )
*str = ( number / 10 ) + '0';
It's still not right but at least the syntax errors have been fixed. I recommend that you run your program in a debugger so you can see what is going on with it. At the very least, add some output statements so you can see the characters as they are added to the string.