for this c program, i'd like to remove the substring "cc" and character "=" from input string "aaccbbccdd" the code below can only remove "cc" once, can somebody help me figure out how to remove other "cc" in the string also how to remove multiple character '=' ?
#include <stdio.h>
#include <string.h>
char *Mystrcpy1(char *s, const char *cs);
void func1(char *src, char *sub);
int main(void)
{
char s[32], *substr = "cc";
Mystrcpy1(s,"==aaccbbccdd");
printf("From the string: \"%s\"\n",s);
printf("We will attempt to remove substring \"%s\"\n",substr);
func1(s,substr);
printf("Using function Mystrcpy1. The result: \"%s\"\n\n",s);
return 0;
}
char *Mystrcpy1(char *s, const char *cs)
{ /* Copy from beginning of string cs to the end */
char *s1;
const char *cs1;
for(s1 = s,cs1 = cs; '\0' != (*s1 = *cs1); s1++,cs1++) ;
return s;
}
void func1(char *src, char *sub)
{ /* Using function Mystrcpy1 */
char *p;
if ((p=strstr(src,sub)) != NULL)
Mystrcpy1(p,p+strlen(sub));
return;
}