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; // error here
As of C++11, the standard C++ library provides the function std::to_string(arg) with various supported types for arg.
std::to_string(arg)
arg
1.4m articles
1.4m replys
5 comments
56.9k users