C++11 introduced some new conversion functions for that exact purpose:
std::to_string() - Integers and float-types to std::string.
Also:
std::stoi() - std::string to int
std::stol() - std::string to long
std::stoul() - std::string to unsigned long
std::stof() - std::string to float
std::stod() - std::string to double
The function-name format is:
stof
s <to> f
string <to> float
Just like the pre-existing atoi() (where 'a' is for ASCII, 'char*' raw-string functions)
This is different from strtof() and the like. I have no clue what those functions do.
([Edit:] Ah, here's an explanation of strtof. I never knew about that function)
Inventing a hot water? Nah, id just use this...
Rereading c++11 is a good idea i see, thanks much.