#include
using namespace std;
void del(char* source, char* sub)
{
char* p = source;
char* q = sub;
char tmpsource[20];
int i = 0;
char *tmp;
while(*p)
{
tmp = p;
while(*q)
{
if(*p == *q)
{
p++;
q++;
}
else
break;
}
if(*q == ‘\0’)
{
q = sub;
}
else
{
tmpsource[i++] = *tmp;
p = tmp+1;
q = sub;
}
}
tmpsource[i] = ‘\0’;
source =tmpsource;
}
int find(char *source, char* sub)
{
char *p = source;
char *q = sub;
char *tmp;
while(*p)
{
tmp = p;
while(*q)
{
if(*p == *q)
{
p++;
q++;
}
else
break;
}
if(*q == ‘\0’)
return tmp-source+1;
else
{
p = tmp+1;
q = sub;
}
}
return 0;
}
int main()
{
char *sub = “ask”;
char *str = “askdaskaskdaskg”;
del(str, sub);
cout << str << endl;
//char *str = “aaaas”;
//int result = find(str, sub);
//cout << result << endl;
return 0;
}