C++ double转string并保留2位小数的两种方法
#include <iostream>#include <iomanip>#include <sstream>std::string doubleToString(const double &val){ char* chCode; chCode = new char[20]; sprintf(chCode, "%.2lf", val); std::string str(chCode); delete[]chCode
原创
2020-08-31 14:57:19 ·
17223 阅读 ·
1 评论