float to char?

This seems simple, but I've been searching for the past hour to figure this out...

Simply put, i have 2 floats, (latitude and longitude) and I want to pass them to my char ip_data with a comma (,) separating them. This way i can send it to my GPRS.

It's frustrating because I'm sure this is super simple.

Any help is greatly appreciated!

dtostrf()

To expand on that a little...

use dtostrf() to convert them both to temporary char arrays, then join them together using sprintf, for example:

char temp1[7];
char temp2[7];
char my_pos[15];
float lat = 14.93;
float lon = 39.19;

dtostrf(lat, 6, 2, temp1);
dtostrf(lon, 6, 2, temp2);
sprintf(my_pos, "%s,%s", temp1, temp2);

(note: untested)

Another way would be to split the floating point numbers up and print them as integers:

char my_pos[15];
float lat = 14.93;
float lon = 39.19;

sprintf(my_pos, "%d.%02d,%d.%02d", (int)lat, ((int)(lat * 100.0)) % 100, (int)lon, ((int)(lon * 100.0)) % 100);

Thank you both, especially majenko!

Doesn’t sprintf() write it out to the serial connection? how would I join these two with a “,” without writing it out to the serial? (im guessing SprintF means serial print format?)

bradburns: Thank you both, especially majenko!

Doesn't sprintf() write it out to the serial connection? how would I join these two with a "," without writing it out to the serial? (im guessing SprintF means serial print format?)

no, the s stands for string. Print formatted into a string.