0

Convert integer in a char array

I want to put an integer (that can start in 0) and print it like it was a char. Just using the funciĂłn write in c language.

11th Feb 2020, 1:07 PM
Kajlar Mola
Kajlar Mola - avatar
3 Answers
0
For example? Can you give an example to understand it clearly...? You mean Input 1 (int) Output 1 (char)? It is better to give a try and post your tried code if it is incomplete?
11th Feb 2020, 1:39 PM
Jayakrishna 🇼🇳
0
You can use sprintf(): int number = 1353; ch_array[] = "hi"; sprintf(ch_array, "%d", number); printf("%d\n", number); printf("%s\n",ch_array); //output : 1353 // number as int 1353 // number as char array
12th Feb 2020, 10:24 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar