字符串中字符的删除
2015-07-03 20:45
417 查看
#include <stdio.h> #include <stdlib.h> #include <string.h> char *fun(char *s,char c) { char *p=s; //用指针p指向字符串s的首地址 char *pp=p; //pp指向字符串p的首地址 for(;*s != '\0';s++) //如果指向的当前字符串不是‘\0’ { if(*s != c) //如果当前字符串不等于指定字符 { *p++ = *s; //将当前字符写入指针p } } *p = '\0’ //字符串末尾增加字符串结束标志 return pp; //返回所得字符串 } int main() { char s[20] = "Hello world!"; printf("%s\n",s); char *ppr; ppr=fun(s,'l'); printf("%s\n",ppr); return 0; }
相关文章推荐
- 如何将Latex转换为Word之Word插入.bib中的文献
- NYOJ 60 谁获得了最高奖学金
- Git教程学习(三)
- php的基础总结
- lodash "collection" methods lodash中文翻译更新中
- 稀疏矩阵求解的一点总结
- Android UI 调试常用工具(Dump view UI hierarchy for Automator)
- c语言常用函数实现
- 模板方法模式
- 初步探索java中的UUID
- 斐波那契shell实现
- 《C++ Primer Plus》学习笔记6
- Unity-EasyTouch插件之One Finger
- 开发OpenDaylight组件的完整流程
- 【动手写排序】选择排序
- 各种排序算法的实现代码
- Cross compile linux kernel
- Unity-EasyTouch插件之One Finger
- 【莫比乌斯反演】关于Mobius反演与lcm的一些关系与问题简化(BZOJ 2154 crash的数字表格&&BZOJ 2693 jzptab)
- NYOJ 770 仿射密码