归纳整理Linux下C语言常用的库函数----内存及字符串控制及操作

本文详细归纳了C语言中常用的内存及字符串控制、操作、转换、连接、分割等函数,包括查找、拷贝、比较、连接、分割、求长等函数,并提供了相应的替换方案和使用说明。

在没有IDE的时候,记住一些常用的库函数的函数名、参数、基本用法及注意事项是很有必要的。

参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类:

  • 1. 内存及字符串控制及操作
  • 2. 字符串转换
  • 3. 字符测试
  • 4. 文件操作
  • 5. 时间日期
  • 6. 常用数学函数
  • 7. 文件内容操作
  • 8. 文件权限控制
  • 9. 进程操作
  • 10. 线程操作
  • 11. Socket操作
  • 12. 信号处理
  • 13. 数据结构及算法

 

 

以下是对第一项 内存及字符串控制及操作 的归纳整理。

 

  • 已经不赞成使用的函数归类
复制代码
*
*           函数名                                                   用途                                    替换方案
*1. int bcmp(const void *s1, const void *s2, size_t n);         compare byte sequences                        memcmp
*
*2. void bcopy(const void *src, void *dest, size_t n);          copy byte sequence                            memcpy Or memmove
*
*3. void bzero(void *s, size_t n);                              write zero-valued bytes                       memset
*
*4. char *index(const char *s, int c);                          locate character in string                    strchr
*
*5. char *rindex(const char *s, int c);                         locate character in string                    strrchr
*
复制代码
  • 内存或字符串查找函数归类
复制代码
*           函数名                                                   用途                                       备注
*1. void *memchr(const void *s, int c, size_t n);       scan memory for a character (Forward)       return a pointer to the matching byte or NULL if the
                                                                                                     character does not occur  in  the  given  memory area.
*
*2. void *memrchr(const void *s, int c, size_t n);      scan memory for a character  (Backward)      return a pointer to the matching byte or NULL if the
                                                                                                     character does not occur  in  the  given  memory area.
*
*3. char *strchr(const char *s, int c);                 locate character in string  (Forward)        return a pointer to the matched character or NULL if
                                                                                                     the character is not found.
*
*4. char *strrchr(const char *s, int c);                locate character in string  (Backward)       return a pointer to the matched character or NULL if
                                                                                                     the character is not found.
*
*5. char *strstr(const char *haystack, const char *needle);       locate a substring                 return a pointer to the beginning of the substring,
                                                                                                     or NULL if the substring is not found.
*
*6. char *strcasestr(const char *haystack, const char *needle);   locate a substring,ignores the     return a pointer to the beginning of the substring,
                                                                  case of both arguments.            or NULL if the substring is not found.
*
复制代码
  • 内存及字符串拷贝、比较函数归类
复制代码
*           函数名                                                  用途                                        备注
*
*1. void *memcpy(void *dest, const void *src, size_t n);        copy memory area                      The memcpy() function returns a pointer to dest.
*
*2. char *strcpy(char *dest, const char *src);                  copy a string                         return a pointer to the destination string dest.
*
*3. char *strncpy(char *dest, const char *src, size_t n);       copy a string                         return a pointer to the destination string dest.
*
*4. void *memmove(void *dest, const void *src, size_t n);       copy memory area , may overlap        returns a pointer to dest.
*
*5. int memcmp(const void *s1, const void *s2, size_t n);       compare memory areas                  returns an integer less than, equal to, or greater than zero if the first n bytes of s1 is found
*
*6. int strcmp(const char *s1, const char *s2);                 compare two strings                   return an integer less than, equal to, or greater than zero if s1 is foundfound
*
*7. int strncmp(const char *s1, const char *s2, size_t n);      compare two strings                   UP
*
*8. int strcasecmp(const char *s1, const char *s2);             compare two strings ignoring case     UP
*
*9. int strncasecmp(const char *s1, const char *s2, size_t n);  compare two strings ignoring case     UP
*
* 10. char *strdup(const char *s);                              duplicate a string                     returns a pointer to a new string which is a duplicate of the string s.  Memory for the new string is obtained with
* 
复制代码
  • 内存或字符串连接、分割、求长等函数归类
复制代码
*           函数名                                                  用途                                            备注
*1. char *strcat(char *dest, const char *src);                  concatenate two strings                 return a pointer to the resulting string dest
*
*2. char *strncat(char *dest, const char *src, size_t n);       UP                                      UP
*
*3. char *strtok(char *str, const char *delim);                 extract tokens from strings             第一次调用时,str必须不为空,第二次调用str必须为空
*
*4. char *strtok_r(char *str, const char *delim, char **saveptr);   可重入函数,线程安全                推荐使用这个分割函数,具体讨论见http://blog.youkuaiyun.com/liuintermilan/article/details/6283705
*
复制代码

 

以上,就是对第一项的整理归纳。接下来,会对第二项 字符串转换  进行归纳。

 

作者: TigerXiao

Email: tiger.xiaowh001@gmail.com

出处: 老虎工作室

说明: 欢迎讨论、转载,转载请注明出处。

分类:  C
标签:  归纳整理
当前,全球经济格局深刻调整,数字化浪潮席卷各行各业,智能物流作为现代物流发展的必然趋势和关键支撑,正迎来前所未有的发展机遇。以人工智能、物联网、大数据、云计算、区块链等前沿信息技术的快速迭代与深度融合为驱动,智能物流不再是传统物流的简单技术叠加,而是正在经历一场从自动化向智能化、从被动响应向主动预测、从信息孤岛向全面互联的深刻变革。展望2025年,智能物流系统将不再局限于提升效率、降低成本的基本目标,而是要构建一个感知更全面、决策更精准、执行更高效、协同更顺畅的智慧运行体系。这要求我们必须超越传统思维定式,以系统化、前瞻性的视角,全面规划和实施智能物流系统的建设。本实施方案正是基于对行业发展趋势的深刻洞察和对未来需求的精准把握而制定。我们的核心目标在于:通过构建一个集成了先进感知技术、大数据分析引擎、智能决策算法和高效协同平台的综合智能物流系统,实现物流全链路的可视化、透明化和智能化管理。这不仅是技术层面的革新,更是管理模式和服务能力的全面提升。本方案旨在明确系统建设的战略方向、关键任务、技术路径和实施步骤,确保通过系统化部署,有效应对日益复杂的供应链环境,提升整体物流韧性,优化资源配置效率,降低运营成本,并最终为客户创造更卓越的价值体验。我们致力于通过本方案的实施,引领智能物流迈向更高水平,为构建现代化经济体系、推动高质量发展提供强有力的物流保障。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值