删除子字符串
#include <stdio.h>#include <string.h>int delete_sub_str(const char *str, const char *sub_str, char *result_str){ int count=0; char *p1=str; char *pos=strstr(str,sub_str); while(pos!=NULL){ count++; while(p1!=pos) *result_str++=*p1++; p1+=strlen(sub_str); pos=strstr(p1,sub_str); } while(*p1!='\0') { *result_str++=*p1++; } *result_str='\0'; return count;}int main(){ char *p1="mabcoabctyuabcq"; puts(p1); char *sub="abc"; char res[20]; int a=delete_sub_str(p1,sub,res); printf("res=%s and count=%d\n",res,a); return 0;}?