使用 ostringstream
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float s = 6.7592;
cout << to_string(s) << endl; // 6.759200
double k = 6.7592;
cout << to_string(k) << endl; // 6.759200
int i = 923342;
cout << to_string(i) << endl; // 923342
ostringstream strStream;
strStream << s;
cout << strStream.str() << endl; // 6.7592
return 0;
}