C++ 类型转换归纳

本篇根据编程遇到的类型转换慢慢往上加东西。


CString 转 int

CString str("123");//如果其中填的不全是数字,则返回从左到右碰到第一个非数字字符前的数字字符数值,如果最左边不是数字字符,返回0
int i= _ttoi(str);


CString 转 char*(UNICODE字符集环境

#include <afxpriv.h>//添加必要的头文件

CString strTest = _T("abcd");//需转换的CString
USES_CONVERSION;
char *p = T2A(strTest);

CString 转 CComVariant

CComVariant cobject;
CString result=L"HAHHAH";
cobject = result;







原文地址:https://www.cnblogs.com/weixinhum/p/3916713.html