输入2个字符串S1和S2,要求删除字符串S1中出现的所有子串S2,即结果字符串中不能包含S2。
输入在2行中分别给出不超过80个字符长度的、以回车结束的2个非空字符串,对应S1和S2。
在一行中输出删除字符串S1中出现的所有子串S2后的结果字符串。
Tomcat is a male ccatat cat
结尾无空行
Tom is a male
结尾无空行
#include<stdio.h> #include<string.h> int main(){ char s1[85],s2[85],temp[85]; char *p; gets(s1); gets(s2); while((p=strstr(s1,s2))!=NULL){ strcpy(temp,p+strlen(s2)); *p='\0'; strcat(s1,temp); } puts(s1); return 0; }