Float to array - itoa

I have been have been working on trying to convert a float to an array for a TFT. There have been many trials and tribulations, but I finally got it to work.

My issue revolved around how to convert a float to a character array, using itoa and keep the decimal place. Basic idea:

char sensor1Char[4];
float pHsensor;
...
 itoa(pHsensor, sensor1Char, 10);
...
Tft.drawString(sensor1Char,200,120,2,WHITE);

This would always come out as only the “Ones” place on the original float and nothing beyond the decimal. Then I found this article regarding an elaborate way to print each significant figure:

In turn I used the values of the global integars F1, F01, F001 for my char array, and got it to print each significant figure.

A post was made by “PaulS” on an easier way to achieve this. Could someone elaborate please?

FormatDouble library.

http://forum.arduino.cc/index.php/topic,148214.0.html

My issue revolved around how to convert a float to a character array, using itoa and keep the decimal place

The clue to your problem may be in the name of the function
From itoa - C++ Reference

Convert integer to string (non-standard function)

Simple and easy. Thanks for your prompt reply. Worked perfectly.

UKHeliBob:

My issue revolved around how to convert a float to a character array, using itoa and keep the decimal place

The clue to your problem may be in the name of the function
From itoa - C++ Reference

Convert integer to string (non-standard function)

I understand that. That is why I had to use that link I posted. Or else it wouldn't work. I actually didn't realize the issue till another person pointed out the same thing. Thank you.

This thread is going in bookmarks. I appreciate it.