What is the most optimal way to achieve the same as this?
void foo(double floatValue, char* stringResult)
{
sprintf(stringResult, \"%f\", floatV
The best thing to do would be to build a simple templatized function to convert any streamable type into a string. Here's the way I do it:
#include
#include
template
const std::string to_string(const T& data)
{
std::ostringstream conv;
conv << data;
return conv.str();
}
If you want a const char* representation, simply substitute conv.str().c_str() in the above.