几何尺寸与公差论坛

 找回密码
 注册
查看: 2221|回复: 0

CString TCHAR的互相转换

[复制链接]
发表于 2007-4-28 14:37:11 | 显示全部楼层 |阅读模式
CString TCHAR的互相转换

CString->TCHAR*的转化可以用函数GetBuff()

函数原型为:LPTSTR GetBuffer( int nMinBufLength );
CString str("CString");
TCHAR* szMsg = new TCHAR[100];
//其参数为CString字符串的长度
szMsg = str.GetBuffer(str.GetLength());
str.ReleaseBuffer();
delete []szMsg;
szMsg = NULL;


TCHAR*->CString的转化

TCHAR szTchar[18] = L"TCHAR";   
CString  str;   
str.Format(_T("%s"),szTchar);
  
//or
// str = szTchar;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-5-13 06:46 , Processed in 0.034671 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表