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

后端 未结 4 488
别那么骄傲
别那么骄傲 2021-01-21 15:51

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:28

    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

提交回复
热议问题