#include<stdio.h>
int del_substr(char *str,char *substr);
int main(){
char str[]="abcdefg";
char substr[]="fg";
if(printf("%s\n",del_substr(str,substr)?"Found It!":"Nothing Found.")==10)
printf("The str is now:\"%s\".\n",str);
return 0;}
//
int del_substr(char *str,char *substr){
char *str_temp=str,*substr_temp=substr,*str_tag=NULL;
for(int flag=0;*str||flag;str++){
if(*str==*substr&&!flag){
str_tag=str;
flag=1;
}
if(flag){
if(*str==*substr&&*substr)
substr++;
else if(*str!=*substr&&*substr){
str=str_tag+1;
substr=substr_temp;
str_tag=NULL;
flag=0;
}
else{
for(str_temp=str,str=str_tag;*str++=*str_temp++;);
return 1;
}
}
}
return 0;}
|