怎样吧一个CString 转化为 double

来源:百度知道 编辑:UC知道 时间:2024/06/17 00:17:12
CString 如何转化为一个double类型
如CString s="123456.789";
转化为double型 的 123456.789

字符串转化为double:

CString s="123456.789";
double d = atof(s);

double转化字符串:
double d = 123456.789;
CString s;
方法一:
s.Format("%f",d);
方法二:
s = ftoa(d);

1.double转化为CString
http://www.sowsoy.com/topics-410.html

C++中doulbe/float/int转为CString方法

在MFC程序中,可以使用Format方法方便的实现int、float和double等数字类型转换为CString字符串。以下是CString的Format支持的格式说明:
%c 单个字符
%d 十进制整数(int)
%ld 十进制整数(long)
%f 十进制浮点数(float)
%lf 十进制浮点数(double)
%o 八进制数
%s 字符串
%u 无符号十进制数
%x 十六进制数
1、int转换为CString

CString str;
int number=15;
//str="15"
str.Format(_T(&qu