C++: what is the optimal way to convert a double to a string?

后端 未结 12 1775
温柔的废话
温柔的废话 2020-12-16 17:09

What is the most optimal way to achieve the same as this?

void foo(double floatValue, char* stringResult)
{
    sprintf(stringResult, \"%f\", floatV         


        
12条回答
  •  粉色の甜心
    2020-12-16 17:37

    I'd say sprintf is pretty much the optimal way. You may prefer snprintf over it, but it doesn't have much to do with performance.

提交回复
热议问题