void remove(char* str, char *substr)
{
int l = strlen(substr);
char* s = str;
int i;
while (*s)
{
if (memcmp(s, substr, l) == 0)
{
memset(s, 0, l);
s += l;
}
else
{
s++;
}
}
i = s - str;
s = str;
while (i)
{
*s = *str;
if (*str != 0) s++;
str++;
i--;
}
*s = 0;
}
int main()
{
char a[] = "adabcddabcdd";
char b[] = "abc";
remove(a, b);
printf("%s", a);
getch();
return 0;
}
温馨提示:答案为网友推荐,仅供参考