#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int delete_sub_str(const char *str, const char *sub_str, char *result_str)
{
const char *p = str;
char *out = result_str;
int len = strlen(sub_str);
int count = 0;
while (*p)
{
p = strstr(p, sub_str);
if (p == NULL)
break;
memcpy(out, str, p-str);
out += p-str;
p += len;
str = p;
count++;
}
*out = '/0';
if (*str != '/0')
strcpy(out, str);
return count;
}
int main()
{
const char *src = "abcde123abcd123abv";
const char *sub = "123";
char *output = (char*)malloc(100);
int num = 0;
num = delete_sub_str(src, sub, output);
puts(output);
return 0;
}