Go Down

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

s3rr00

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?

KeithRB

Sure, check out itoa()
http://playground.arduino.cc/Code/PrintingNumbers


guix

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 );

Arrch


is there an easier way to do this?


How much easier are you looking to get?

Go Up