Try using sprintf
:
unsigned long x=1000000;
char buffer[21];
sprintf(buffer,"%lu", x);
Edit:
Notice that you have to allocate a buffer in advance, and have no idea how long the numbers will actually be when you do so. I'm assuming 32bit long
s, which can produce numbers as big as 10 digits.
See Carl Smotricz's answer for a better explanation of the issues involved.