#include <stdio.h>
#include <string.h>
char del(char *str, char *ch);
void main()
{
char *str, *ch,*str_after;
printf("Please input the words:\n");
gets(str);
printf("Pleased input a word:\n");
gets(ch);
*str_after=del(str,ch);
printf("The delete is:\n");
puts(str_after);
}
char del(char *str, char *ch)
{
int len1=strlen(str),len2=strlen(ch);
int i,j,pos;
char *p;
while(1)
{
p=strstr(str,ch);
if(p==NULL) break;
else
{
pos=p-str;
for(i=pos;i<len1-len2;i++)
{
*(str+i)=*(str+i+len2);
}
*(str+len1-len2)='\0';
}
//else break;
}
return *str;
}
#include <string.h>
char del(char *str, char *ch);
void main()
{
char *str, *ch,*str_after;
printf("Please input the words:\n");
gets(str);
printf("Pleased input a word:\n");
gets(ch);
*str_after=del(str,ch);
printf("The delete is:\n");
puts(str_after);
}
char del(char *str, char *ch)
{
int len1=strlen(str),len2=strlen(ch);
int i,j,pos;
char *p;
while(1)
{
p=strstr(str,ch);
if(p==NULL) break;
else
{
pos=p-str;
for(i=pos;i<len1-len2;i++)
{
*(str+i)=*(str+i+len2);
}
*(str+len1-len2)='\0';
}
//else break;
}
return *str;
}