请问怎么把CString转换成BYTE?

woshirenyi 2004-09-17 03:15:00
请问怎么把CString转换成BYTE?
...全文
320 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
reludson 2004-09-17
  • 打赏
  • 举报
回复
CString str="ok,go";
BYTE bt[100];
memset(bt,0,sizeof(bt));
memcpy(bt,str,str.GetLength());
gdy119 2004-09-17
  • 打赏
  • 举报
回复
up!
woshirenyi 2004-09-17
  • 打赏
  • 举报
回复
这个好象不行呀
huaboy408 2004-09-17
  • 打赏
  • 举报
回复
Use the method 'GetBuffer' but be careful with UNICODE where one char is 2
bytes and not 1

From MSDN:
// example for CString::GetBuffer
CString s( "abcd" );
#ifdef _DEBUG
afxDump << "CString s " << s << "\n";
#endif
LPTSTR p = s.GetBuffer( 10 );
lstrcpy( p, _T("Hello") ); // directly access CString buffer
s.ReleaseBuffer( );
#ifdef _DEBUG
afxDump << "CString s " << s << "\n";
#endif
arvid_gs 2004-09-17
  • 打赏
  • 举报
回复
GetBuffer

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧