如何把BYTE数组的值传给CString? BYTE aa[4];CString bb;BYTE----->CString如何实现! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BYTE aa[4];CString bb;bb.Format((char *)aa); 如果aa是英文字符串的话,可以这样:bb = CString(aa); BYTE* temp = new BYTE [buffer.GetSize()]; CString AppStr; for (int i=0; i<4; i++) { temp[i] = buffer[i]; temp[i] = ((temp[i]<<4) | (temp[i]>>4)); } AppStr.Format((char *)temp);temp[0]=0x11,temp[1]=0x22,temp[2]=0x33,temp[4]=0x44;为什么在watch窗口看不到AppStr的值为11223344? 大哥拜托,你这明明是要把16进制转换程字符串嘛,题目要写清楚嘛:BYTE temp[4] = {0x11,0x22,0x33,0x44};CString AppStr;AppStr.Format("%02x%02x%02x%02x",temp[0],temp[1],temp[2],temp[3]);::MessageBox(NULL,(LPCTSTR)AppStr,NULL,MB_OK); 按照lonely001的方法可以,但我的temp数组的个数不确定,可能为10个,不会AppStr.Format("%02x%02x%02x%.....02x",temp[0],temp[1],temp[2],temp[3].....);一个一个输吧! for(int i =0;i<len;i++){ CString str.Format("%02x",temp[i]); AppStr+=str;} void *memcpy( void *dest, const void *src, size_t count );MSDN上有详尽解释. example:BYTE m_Byte[10]={'A','B','C','D','E','F','G','H'};char cBuffer[100];memcpy(cBuffer,m_Byte,sizeof(m_Byte));CString szBuffer = cBuffer; 楼上有个小错误应该为cBuffermemset(cBuffer, 0, 100);再进行memcpy否则字符串没有结束岂不是烫烫烫烫... BYTE* temp = new BYTE [buffer.GetSize()];CString AppStr = "";for (int i=0; i<buffer.GetSize(); i++){ temp[i] = buffer[i]; temp[i] = ((temp[i]<<4) | (temp[i]>>4)); AppStr.Format("%s%02x",(LPCTSTR)AppStr,temp[i]);}delete [] temp; Access的模糊查询问题 添加一个类的头文件出错 宏定义的问题 菜鸟请教高手~~~~~~~~~~~ 关于微软磁盘碎片整理,扫描的API? 关于EDIT控件和自定义类的2个问题,高手有功夫看一眼,谢谢 请高人指点一下!!! 大家毕业设计都做什么题目啊?? 高分求教,如何取得当前登陆用户? vc封闭图形填充 MSComm发送中文时接收方怎样把汉字变成了0.(在线等) 安装visual c++时最后提示javasign.dll 无法写注册到数据库
CString bb;
bb.Format((char *)aa);
bb = CString(aa);
CString AppStr;
for (int i=0; i<4; i++)
{
temp[i] = buffer[i];
temp[i] = ((temp[i]<<4) | (temp[i]>>4));
}
AppStr.Format((char *)temp);
temp[0]=0x11,temp[1]=0x22,temp[2]=0x33,temp[4]=0x44;为什么在watch窗口看不到AppStr的值为11223344?
BYTE temp[4] = {0x11,0x22,0x33,0x44};
CString AppStr;
AppStr.Format("%02x%02x%02x%02x",temp[0],temp[1],temp[2],temp[3]);
::MessageBox(NULL,(LPCTSTR)AppStr,NULL,MB_OK);
AppStr.Format("%02x%02x%02x%.....02x",temp[0],temp[1],temp[2],temp[3].....);一个一个输吧!
{
CString str.Format("%02x",temp[i]);
AppStr+=str;
}
char cBuffer[100];
memcpy(cBuffer,m_Byte,sizeof(m_Byte));
CString szBuffer = cBuffer;
应该为cBuffer
memset(cBuffer, 0, 100);
再进行memcpy
否则字符串没有结束
岂不是烫烫烫烫...
CString AppStr = "";
for (int i=0; i<buffer.GetSize(); i++)
{
temp[i] = buffer[i];
temp[i] = ((temp[i]<<4) | (temp[i]>>4));
AppStr.Format("%s%02x",(LPCTSTR)AppStr,temp[i]);
}
delete [] temp;