//convert string type value to double
type value
string s = "23";
double d;
istringstream
is(s);
is>>d;
cout<<d<<endl; //输出23
//convert double type value to string
type value
double d=45;
string s;
ostringstream
os;
os<<d;
s = os.str();
cout<<s<<endl;
//输出45
C++中string类型对象和double型变量之间的互相转换,布布扣,bubuko.com
时间: 2024-12-04 13:42:10