二进制数据打印

来源:互联网 发布:百度大数据足球分析 编辑:程序博客网 时间:2024/05/17 07:18
char strtmp[1024*6] = {'\0'};
for( int i = 0 ; i < nmsg.head.len; i++)
{
char tmp[128] = {'\0'};
if( (i+1) % 16 != 0 )
sprintf(tmp," %2x ",0xff & nmsg.buf[i] );
else
sprintf(tmp,"\n %2x ",0xff & nmsg.buf[i] );
strcat(strtmp,tmp);
}

strcat(strtmp,"\n");

printf("%s",strtmp);

0 0
原创粉丝点击