如何将char数组转换为CString? [英] How to convert char array to CString?

查看:1523
本文介绍了如何将char数组转换为CString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将char数组转换为CString? CString应该接受其中的NULL字符。 char数组包含二进制数据。

How to convert char array to CString? the CString should accept the NULL characters in it. char array contains the binary data.

推荐答案

检查此链接以进行各种转换-> [ ^ ]
Check this link for various conversion ->[^]


这个怎么样,

What about this,
TCHAR * p = _T("This is a test");
CString s = p;





阅读本文了解CString管理,

CString管理 [ ^ ]


如果您的 CString 应该包含确切的字符数组的二进制副本(但是,这种要求的目的是什么?)然后你必须使用 GetBuffer / ReleaseBuffer 方法,例如:



If your CString should contain the exact binary copy of the character array (however, what is the purpose of such a requirement?) then you have to use GetBuffer/ReleaseBuffer methods, for instance:

char p[] = {0x10,0x41, 0x00, 0x45};
CStringA foo;
memcpy(foo.GetBufferSetLength(sizeof(p)), p, sizeof(p));
foo.ReleaseBuffer(sizeof(p));


这篇关于如何将char数组转换为CString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆