65,203
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
double strtod(const char * restrict nptr, char ** restrict endptr);
float strtof(const char * restrict nptr, char ** restrict endptr);
long double strtold(const char * restrict nptr, char ** restrict endptr);
double temp ;
string out_text = "11374.15";
const char *str = out_text.c_str();
cout<<str<<endl;
temp = atof(str);
cout<<temp<<endl;
string a = "4.42";
double s = atof(a.c_str());
cout<<s<<endl;
double temp;
const char *str="27.25";
cout<<str<<endl;
temp = (double)atof(str);
cout<<temp<<endl; string a = "4.42";
double s = atof(a.c_str());
cout<<s<<endl; cout<<out_text<<endl;
temp = (double)atof(out_text.c_str());
cout<<temp<<endl;
double temp;
string out_text;
...
cout<<out_text.c_str()<<endl; //out_text的内容来自文件
temp = (double)atof(out_text.c_str());