Arm Mbed OS support forum

How to convert Float numbers to STRING then concatenate them?

Hello everyone
I want to convert some float values to string then concatenate both in order to add them to a link but it seems not to work . Below is my code, kindly have a look and tell me my mistake or error .

#include "mbed.h"
#include <iostream> 
#include <string>
using std::string;

gpsCoordinates = gps.getGPS(&fix, &latitude, &longitude, &MSL_altitude, &speed_kph, &heading);
string str_lati(std::string(latitude)); 
string str_long(std::string(longitude));

string coord_string = str_lati + ' , ' + str_long ;  // There is an error here
string c = "";
String map_link = c + coord_string ;  // Here is the link to access the location on google map

// NB : the conversion to string has worked, but the concatenation thrown an error

Please note that , this is not the full code , I have just showed you the part for the issue, I will be grateful if you can help.

Thanks in advance .


try to change this

' , '

to this

", "

For float conversion you can try to check

BR, Jan