Go Down

Topic: Integer to string (Read 9303 times) previous topic - next topic


Hi all.

I'm starting with the C of arduino and I need a way to convert an integer value to a string or array of chars in order to display it on an LCD. Something like this:
printf ( s_myString, "%d", i_myInteger);

The problem is that I cannot find nothing like this in the reference. I was wondering if there are something written to manipulate number to string conversion before starting to write my own functions.

Tanks ;)


there are a number of ways to do it , for a start have a google at itoa


Jun 29, 2008, 08:36 pm Last Edit: Jun 29, 2008, 08:42 pm by BroHogan Reason: 1
You can use   itoa(i_myInteger, s_myString, 10);                // the 10 is the "base" of the int - leave at 10.
Edit: Sorry mem - simo-post.
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll


Thanks both!

I thought that the available functions were limited to the ones on the extended reference page, but I see that there is more and I can try in the future all the standard C ;)

Now my small little robot can "see" and shows the LDR values on the debugging LCD.


What would be the easiest way to do a float to string (also for printing to an lcd)?
It doesn't look like there's an ftoa.


Chris, there is code posted here that will print floating points with up to four decimal places : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207226548


Go Up