Convert long long to string in C?

Tommy picture Tommy · Apr 19, 2013 · Viewed 49.3k times · Source

I'd like to convert a long long to a string in C.

long long x = 999;

I'd like to convert x to a string. How could I go about doing that?

Thanks.

Answer

Ziffusion picture Ziffusion · Apr 19, 2013
long long x = 999;
char str[256];
sprintf(str, "%lld", x);
printf("%s\n", str);