64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
const int MaxLen = 100 ;
int main()
{
double d = 1.722300;
char s[MaxLen];
sprintf(s,"%f",d);
string str(s);
cout << str << endl;
return 0;
}
Converts a floating-point number to a string. This function is deprecated because a more secure version is available; see _fcvt_s.
char *_fcvt(
double value,
int count,
int *dec,
int *sign
);
stringstream strstm;
double d=11111.1;
strstm<<d;
string str=strstm.str();
cout<<str<<endl;