double nValue = 1.02 =如何转换成=> stl string = "1.02"
double nValue = 1.02 =如何转换成=> stl string = "1.02"
mfc 的CString::Fromat();
stl string 如何实现的
[解决办法]
- C/C++ code
#include <iostream>#include <sstream>#include <string>using namespace std;int main(){ double nValue = 1.02; stringstream stream; string result; int i = 1000; stream << nValue; stream >> result; cout << result << endl;}
[解决办法]
char buf[5];
sprintf(buf,"%.2f",nValue);
[解决办法]
[解决办法]
1.s.Format("%g",nValue);//s DateType:CString
2.char buf[10];
sprintf(buf,"%g",nValue);
string Str(buf);