怎么将CString类型的数字字符串转化浮点型?

来源:百度知道 编辑:UC知道 时间:2024/05/31 01:57:30
如题。

使用函数
double atof( const char *string );
比如char *s; double m;
m=atof(s );//把s数字字符串转换为double

这是在#include<math.h>的

如果是VC6用 atof
如果是VS2005或VS2008用 _tstof (单字符集和UNICODE编码都可以用)

CString str = _T("123.456");

//VS2005或VS2008用
double a = _tstof(str);

//VC6用
double b = atof(str);