#include <stdio.h>
#include <string.h>
int main()
{
char str[] = "askdaskaskdaskg";
char del[] = "a";
char* p;
char* q;
int strLen = strlen(str);
int delLen = strlen(del);
char* buf = new char[strLen+1];
char* r = buf;
// 初始化数据
p = str;
// 找到第一个想要删除的字符串
q = strstr(p, del);
while(q!=NULL)
{
// 复制剩余字符串
while(p<q)
{
*r++ = *p++;
}
// 跳过删除的字符串
p = q+delLen;
// 查找第二个欲删除的字符串
q = strstr(p, del);
}
// 复制剩余的字符串
while(*p)
{
*r++ = *p++;
}
*r = 0;
printf("%s\n", buf);
return 0;
}
阅读(999) | 评论(0) | 转发(0) |