MFC 中将字符串 与数值之间的转换 _tstof _wtoi

将字符串转换为双精度

注:Unicode下可使用_wtof。不过最好使用_tstof,它实际上是宏,在不同的字符集下解释不同。这样两种字符集都可以编译通过。

CString str(_T("4.567"));
double Text = _tstof(str);

将字符串转换为 int 类型

CString str(_T("warning"));
int data = _wtoi(str);


猜你喜欢

转载自blog.csdn.net/p942005405/article/details/79653625