设为首页 加入收藏

TOP

C/C++字符串处理函数
2014-11-24 12:33:28 来源: 作者: 【 】 浏览:0
Tags:C/C 字符串 处理 函数

这里介绍的函数主要有:strcat, strcmp, strcasecmp, strcpy, strdup, strlen, strchr, strrchr, strstr, strpbrk, strspn, strcspn, strtok. 在本章的最后还会给出这些库函数的具体实现,以应付一些企业的面试。


文章共分四个部分,第一部分直接列出了常用的字符串处理函数,由于这些都是大家平时接触的比较多的,在此不再多说;第二部分介绍了不太常用的字符串处理函数,并给出了具体示例,很多函数看名字很难猜到它的具体作用,但是一个小小的例子就能解释得很清楚;第三部分给出了这些函数的具体实现,大部分参考网上个人认为已经不错的实现,部分是查看glibc源代码后,简化得来的程序;第四部分作者非常道德的给出了参考资料。



常用的字符串处理函数:


char *strcat(char *s1, const char *s2);


size_t strlen(const char *s1);


不太常用的字符串处理函数:




//the strdup() function allocates memory and copies into it the string addressed s1. including the terminating null character.


//It is the use's responsibility to free the allocated storage by calling free()


char *strchr(const char *s1, int c);





char *strrchr(const char *s1, int c);


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇求二叉树中和为给定值的所有路径 下一篇Spring MVC 注解-让Spring跑起来

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·MySQL 安装及连接-腾 (2025-12-25 06:20:28)
·MySQL的下载、安装、 (2025-12-25 06:20:26)
·MySQL 中文网:探索 (2025-12-25 06:20:23)
·Shell脚本:Linux Sh (2025-12-25 05:50:11)
·VMware虚拟机安装Lin (2025-12-25 05:50:08)