📄 subject_49826.htm
字号:
<p>
序号:49826 发表者:夏雪宜 发表日期:2003-08-14 09:03:58
<br>主题:如何将一个UCHAR转换成字符串,help!help!help
<br>内容:我遇见一个问题如下:<BR> UCHAR temp[3];<BR> temp[0]=0x33;<BR> temp[1]=0x44;<BR> temp[2]='\0';<BR> CString str;<BR> str.Format("%s",temp);<BR> AfxMessageBox(str);<BR> 现在的输出结果是3D,因为33时对应的ASCII的字符是'3',而44对应的字符是‘D’;但我想输出的结果是0x33和0x44这样的字符串,应该如何实现?请各位帮个忙<BR><BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:charle888 回复日期:2003-08-14 10:49:42
<br>内容: #define N 3<BR> int i;<BR> CString str,strtmp;<BR> UCHAR temp[N];<BR> temp[0]=0x33;<BR> temp[1]=0x44;<BR> temp[2]='\0';<BR> <BR> for(i=0;temp[i]!='\0';i++)<BR> {<BR> strtmp.Format("0x%x",temp[i]); //"%x"为16进制输出<BR> str=str+strtmp+","; //字符串连接<BR> }<BR> AfxMessageBox(str);
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -