Double to Const Char*

前端 未结 4 825
既然无缘
既然无缘 2021-01-11 17:55

How can I convert a double into a const char, and then convert it back into a double?

I\'m wanting to convert the double to a string, to write it to a file via fput

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-11 18:40

    Use this funcition :

    const char* ConvertDoubleToString(double value){
        std::stringstream ss ;
        ss << value;
        const char* str = ss.str().c_str();
        return str;
    }
    

提交回复
热议问题