删除字符串中的子字符串
来源:互联网 发布:上海煜麦网络招聘骗局 编辑:程序博客网 时间:2024/05/07 05:30
int del_substr(char *str, char const *substr){int hasSubStr = 0;int offset = 0;int del_position = 0;while(*(str + del_position) != '\0'){offset = 0;while(*(substr + offset)!= '\0' ){if(*(substr + offset) != *(str + del_position + offset)){del_position++;break;}offset++;}if(*(substr + offset)== '\0'){hasSubStr = 1;break;} else {hasSubStr = 0;}}printf("str = %s, substr = %s \n",str, substr);int i = 0;do{*(str+del_position + i) = *(str + del_position + offset + i);}while(*(str + del_position + offset + i++) != '\0');printf("str final = %s \n",str);return hasSubStr;}
亲测有效
0 0
- 删除字符串中的子字符串
- 删除字符串中的子串
- 删除字符串中的子串
- 删除字符串中的子串
- 删除字符串中的子串
- 删除字符串中的子串
- 删除字符串中的子串
- 删除字符串中的子串
- 删除字符串中的子串
- C++ 删除字符串中的指定子字符串
- 删除字符串中的给定子串
- <记录>删除字符串中的子串
- 删除字符串中的子串(20)
- 删除字符串中的特定子串
- 删除指定字符串中的子串
- 5-29 删除字符串中的子串
- 删除字符串中的子串 PAT
- 【C++】删除字符串中的子串
- 算法整理(二)---快速排序的两种实现方式:双边扫描和单边扫描
- 火山旅
- java中父类和子类的关系
- [备战NOI同步赛]适合ACM-ICPC的高精度运算结构体Hugeint的实现
- java简单计算器
- 删除字符串中的子字符串
- 面向对象设计的七大原则
- The Beauty contest game
- OpenCL多卡编程
- 复制删除移动命令 ubuntu
- POJ 2451 Uyuw's Concert(半平面交,求面积,裸)
- 负载均衡算法
- 中介者(Mediator)
- 'this' in JS