Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert long long to string in C?

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.

like image 252
Tommy Avatar asked Apr 19 '13 00:04

Tommy


People also ask

Can you convert a long to a string?

The Long. toString() method converts long to String. The toString() is the static method of Long class.

Is there an itoa in C?

The itoa (integer to ASCII) function is a widespread non-standard extension to the standard C programming language. It cannot be portably used, as it is not defined in any of the C language standards; however, compilers often provide it through the header <stdlib.

How does itoa work in C?

The itoa() function coverts the integer n into a character string. The string is placed in the buffer passed, which must be large enough to hold the output. The radix values can be OCTAL, DECIMAL, or HEX.


1 Answers

long long x = 999;
char str[256];
sprintf(str, "%lld", x);
printf("%s\n", str);
like image 132
Ziffusion Avatar answered Sep 28 '22 09:09

Ziffusion