Try this. Keep in mind, the code will modify the string directly.
Code:
#include <string.h>
void RemoveWords(char *str);
int main(int argc, char* argv[])
{
char str[81];
strcpy(str, "<this> is some <test> data");
RemoveWords(str);
return 0;
}
void
RemoveWords(char *str)
{
#define START_CHAR '<'
#define END_CHAR '>'
char *p;
char *t;
p = str;
t = p;
while (*t) // while we haven't found the end of the string
{
if (*t == START_CHAR)
{
while (*t && *t != END_CHAR) // look for the END_CHAR
{
t++;
}
t++; // skip the END_CHAR
}
*p = *t; // finally, copy the current character
p++;
t++;
if (*t == '\0')
*p = '\0';
}
}