I have a float value that needs to be put into a std::string. How do I convert from float to string?
std::string
float val = 2.5; std::string my_val = val;
You can define a template which will work not only just with doubles, but with other types as well.
template string tostr(const T& t) { ostringstream os; os<
Then you can use it for other types.
double x = 14.4; int y = 21; string sx = tostr(x); string sy = tostr(y);