Here’s my function call:
removeTags(*buf, bufSize);
which calls:
void removeTags(char* dataBlock, unsigned long size)
{
char* start = dataBlock;
char* end = dataBlock + size;
while(start < end)
{
//How do I replace the characters "\abc" with just nothing, ''.
}
I want to replace any instances of the characters \abc with nothing.
Once you find an instance of
\abcsimply move all the characters after the\abcbackwards four places (four because\abcis four chars long) (possibly usingmemmove).For instance:
Note that after you do that, your
endpointer will be invalidated so you’ll have to update it.Finding the position of a string within another string can be done with
strstrforconst char*s orstd::string::findforstd::strings. Of course, if you’re usingstd::string, then you could just usestd::string::replace.