use printf to print character string in hex format, distorted results

前端 未结 2 1264
旧时难觅i
旧时难觅i 2021-02-06 05:00

I want to print character string in hex format,

on machine A , something like

ori_mesg = gen_rdm_bytestream (1400,seed)
sendto(machine B, ori_mesg, len(m         


        
2条回答
  •  情深已故
    2021-02-06 05:30

    Yup, always print string in hex format as:

    for(i=0;till string length;i++)
    printf("%02X",(unsigned char)str[i]);
    

    you will get error when you try to print

    the whole string in one go and when printing Hex string character by character which using 'Unsigned char' if the string is in format other than 'Unsigned char'

提交回复
热议问题