How to print a string with embedded nulls so that “(null)” is substituted for '\0'

后端 未结 4 1459
天涯浪人
天涯浪人 2021-01-21 15:32

I have a string I composed using memcpy() that (when expanded) looks like this:

char* str = \"AAAA\\x00\\x00\\x00...\\x11\\x11\\x11\\x11\\x00\\x00...\";
<         


        
4条回答
  •  礼貌的吻别
    2021-01-21 16:05

    Instead of printing the string with %s , you will have to come up with a for loop that checks a condition whther a given char in your char array is a \0 and then print the NULL

提交回复
热议问题