Go Down

Topic: Is it possible to convert a int into a string? (Read 1 time) previous topic - next topic


I am using a Seeed Studio TouchShield. I want to display an int on the screen. But the code only allows me to print chars and strings. I want to know if I can convert a int into a string or char. Basically what I'm asking do the following:
int=1, int=sting/char, string/char=1. Is this possible?


Sure, check out itoa()



If the number is between 0 and 9 then you can do
Code: [Select]
char c = number + '0';

If number is bigger then no there is not an easier solution than itoa, but there is another solution that is sprintf
Code: [Select]

char string[12];
sprintf( string, "%d", number );
print( string );


is there an easier way to do this?

How much easier are you looking to get?

Go Up