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...\";
<
One of the key cornerstones of C is strings are terminated by '\0'. Everyone lives by that rule. so I suggest you not think of your string as a string but as an array of characters.
If you traverse the array and test for '\0', you can print "(null)" out in place of the character. Here is an example. Please note, your char * str
was created either as a char array or on the stack using malloc
. This code needs to know the actual buffer size.
char* str = "AAAA\x00\x00\x00...\x11\x11\x11\x11\x00\x00...";
int iStrSz =
int idx;
for(idx=0; idx