Go Down

Topic: Is it possible to convert a int into a string? (Read 574 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

s3rr00


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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy