Working with strings in C that contain multiple Null characters

Viewed 3461

I have a char[] buffer that contains data read from the memory, which means there are multiple Nulls within this buffer and not only one single terminating Null at the end.

char *addr = (char *)memmem(buff, strlen(buff), needle, strlen(needle));

I need to process this string and search and replace certain content. For this, I would like to use memmem(), but unfortunately, it's not working because the multiple Nulls within the buffer.

I tried to replace the Nulls in the buffer with a character from which I thought it would not appear (the Bell ASCII code \7) and then process it, but this does not work and corrupts my data.

Is there another way to process a string that has multiple Nulls?

3 Answers
Related