二进制数据打印

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);

你可能感兴趣的:(二进制数据打印)