c int to string
To convert an int
to a string in C, you can use the sprintf
function or the itoa
function.
Here's an example using sprintf
:
int num = 123;
char str[10];
sprintf(str, "%d", num);
And here's an example using itoa
:
int num = 123;
char str[10];
itoa(num, str, 10);
In both cases, the resulting string will be stored in the str
variable. Note that the size of the str
array should be large enough to accommodate the converted string.
Please let me know if you need any further assistance!