作者timohu ( )
看板C_and_CPP
标题Re: [问题] 如何把字串转成ASCII code
时间Fri Feb 13 17:07:52 2009
我在说明一下好了@@
有一个字串
CString team;
team = _T("BOS");
然後我的传送buff第4~6是队名
team.Mid(0,1)-->"B".......
本来想说用
outbuff[4] = (LPCSTR)team.Mid(0,1);
但会出现 cannot convert from 'const char *' to 'unsigned char'的错误
※ 引述《timohu ( )》之铭言:
: 我是用MFC在写一个视窗程式
: 因为在通讯部分是用数字再传的
: ex:
: outbuff[0] = 0xA;
: outbuff[1] = 0xB;.......
: 假设现在outbuff[4~6]是"BOS" 这样的资料
: 那我要用什麽方法让
: outbuff[4] = 0x42;
: outbuff[5] = 0x4f;
: outbuff[6] = 0x53;
: (我是用WriteFile()把资料传送出去的)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.87.152.131
1F:→ fuha:错误讯息不是写的很清楚了吗? 另外你要注意你的字串是_T() 02/13 17:24
2F:→ akasan:outbuff[4] = *(LPCSTR)team.Mid(0,1); 02/13 17:32