How to convert integer value to string in C langauge? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to convert integer value to string in C langauge?

18th Jan 2021, 4:35 PM
Samir Kaushik
Samir Kaushik - avatar
4 Answers
+ 3
#include <stdio.h> ... int value = 0; char textvalue[30] = ""; ... snprintf(textvalue, sizeof(textvalue), "%d", value);
18th Jan 2021, 5:20 PM
Vasile Eftodii
Vasile Eftodii - avatar
+ 3
Means do you want to convert 1 to '1' Or 1 to 'A' in either case you can make use of the fact that characters are represented by their ASCII values which are integers.
18th Jan 2021, 4:38 PM
Arsenic
Arsenic - avatar
18th Jan 2021, 4:37 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
Arsenic 12 to "12" so that i concatenate to some other string
18th Jan 2021, 4:40 PM
Samir Kaushik
Samir Kaushik - avatar