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

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

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

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

  • 已经不赞成使用的函数归类
  1. *
  2. * 函数名 用途 替换方案
  3. *. int bcmp(const void *s1, const void *s2, size_t n); compare byte sequences memcmp
  4. *
  5. *. void bcopy(const void *src, void *dest, size_t n); copy byte sequence memcpy Or memmove
  6. *
  7. *. void bzero(void *s, size_t n); write zero-valued bytes memset
  8. *
  9. *. char *index(const char *s, int c); locate character in string strchr
  10. *
  11. *. char *rindex(const char *s, int c); locate character in string strrchr
  12. *
  • 内存或字符串查找函数归类
  1. * 函数名 用途 备注
  2. *. 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
  3. character does not occur in the given memory area.
  4. *
  5. *. 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
  6. character does not occur in the given memory area.
  7. *
  8. *. char *strchr(const char *s, int c); locate character in string (Forward) return a pointer to the matched character or NULL if
  9. the character is not found.
  10. *
  11. *. char *strrchr(const char *s, int c); locate character in string (Backward) return a pointer to the matched character or NULL if
  12. the character is not found.
  13. *
  14. *. char *strstr(const char *haystack, const char *needle); locate a substring return a pointer to the beginning of the substring,
  15. or NULL if the substring is not found.
  16. *
  17. *. char *strcasestr(const char *haystack, const char *needle); locate a substring,ignores the return a pointer to the beginning of the substring,
  18. case of both arguments. or NULL if the substring is not found.
  19. *
  • 内存及字符串拷贝、比较函数归类
  1. * 函数名 用途 备注
  2. *
  3. *. void *memcpy(void *dest, const void *src, size_t n); copy memory area The memcpy() function returns a pointer to dest.
  4. *
  5. *. char *strcpy(char *dest, const char *src); copy a string return a pointer to the destination string dest.
  6. *
  7. *. char *strncpy(char *dest, const char *src, size_t n); copy a string return a pointer to the destination string dest.
  8. *
  9. *. void *memmove(void *dest, const void *src, size_t n); copy memory area , may overlap returns a pointer to dest.
  10. *
  11. *. 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
  12. *
  13. *. 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
  14. *
  15. *. int strncmp(const char *s1, const char *s2, size_t n); compare two strings UP
  16. *
  17. *. int strcasecmp(const char *s1, const char *s2); compare two strings ignoring case UP
  18. *
  19. *. int strncasecmp(const char *s1, const char *s2, size_t n); compare two strings ignoring case UP
  20. *
  21. * . 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
  22. *
  • 内存或字符串连接、分割、求长等函数归类
  1. * 函数名 用途 备注
  2. *. char *strcat(char *dest, const char *src); concatenate two strings return a pointer to the resulting string dest
  3. *
  4. *. char *strncat(char *dest, const char *src, size_t n); UP UP
  5. *
  6. *. char *strtok(char *str, const char *delim); extract tokens from strings 第一次调用时,str必须不为空,第二次调用str必须为空
  7. *
  8. *. char *strtok_r(char *str, const char *delim, char **saveptr); 可重入函数,线程安全 推荐使用这个分割函数,具体讨论见http://blog.csdn.net/liuintermilan/article/details/6283705
  9. *

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

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

  1. 归纳整理Linux下C语言常用的库函数----文件操作

    在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...

  2. 归纳整理Linux下C语言常用的库函数----时间日期数学及算法

    在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...

  3. 归纳整理Linux下C语言常用的库函数----字符串转换、字符测试、及内存控制

    在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...

  4. 笔记整理——Linux下C语言正则表达式

    Linux下C语言正则表达式使用详解 - Google Chrome (2013/5/2 16:40:37) Linux下C语言正则表达式使用详解 2012年6月6日Neal627 views发表评论 ...

  5. LINUX下C语言编程基础

    实验二 Linux下C语言编程基础 一.实验目的 1. 熟悉Linux系统下的开发环境 2. 熟悉vi的基本操作 3. 熟悉gcc编译器的基本原理 4. 熟练使用gcc编译器的常用选项 5 .熟练使用 ...

  6. Unix和Linux下C语言学习指南

    转自:http://www.linuxdiyf.com/viewarticle.php?id=174074 Unix和Linux下C语言学习指南 引言 尽管 C 语言问世已近 30 年,但它的魅力仍未 ...

  7. LINUX下C语言编程调用函数、链接头文件以及库文件

    LINUX下C语言编程经常需要链接其他函数,而其他函数一般都放在另外.c文件中,或者打包放在一个库文件里面,我需要在main函数中调用这些函数,主要有如下几种方法: 1.当需要调用函数的个数比较少时, ...

  8. Linux下提权常用小命令

    有些新手朋友在拿到一个webshell后如果看到服务器是Linux或Unix操作系统的就直接放弃提权,认为Linux或Unix下的提权很难,不是大家能做的,其实Linux下的提权并没有很多人想象的那么 ...

  9. linux下C语言多线程编程实例

    用一个实例.来学习linux下C语言多线程编程实例. 代码目的:通过创建两个线程来实现对一个数的递加.代码: //包含的头文件 #include <pthread.h> #include ...

随机推荐

  1. poj 3744 概率dp 快速幂 注意排序 难度:2

    /* Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5304   Accepted: 1455 De ...

  2. Life Cycle(JSF+Facelets)

    一.JSF Life Cycle: 图1 图2 应用程序的生命周期是指应用程序的各个阶段,从开始到结束.所有应用程序的生命周期.在web应用程序生命周期中,执行常见任务,包括以下内容.■处理传入的请求 ...

  3. Linux下各文件夹的含义和用途

    Linux根目录”/“下各个系统文件夹的含义和用途 1./boot 该目录默认下存放的是Linux的启动文件和内核. 2./initrd 它的英文含义是boot loader initialized ...

  4. 老爷机iphone4s 9.2.1降级6.1.3

    原帖见威锋网 sunnyskyline 2017年1月10日发的贴. 本文中加了一些我自己的情况,也是一知半解,抛砖引玉吧. 首先进行备份.进行备份.进行备份. 感谢大神@极端阴险 感谢@shuaig ...

  5. Python源码分析之dis

    一.简单例子 def add(a, b): return a + b add_nums.py import foo a = [1, 'python'] a = 'a string' def func( ...

  6. ambassador 学习九 多ambassador部署说明

    目前官方稳文档没有写,但是demo 里面有,所以就整理出来,其实目前demo里面的 多实例部署用了多个服务的service(使用nodeport 暴露地址,具体使用就是制定ambassador 实例的 ...

  7. linux-一篇文章完成lnmp环境的编译安装

    lnmp环境搭建 前置条件 操作系统安装:CentOS 6.8 64位最小化安装. 配置好IP.DNS.网关.主机名 配置防火墙,开启80.3306端口 关闭访问墙 service iptables ...

  8. CentOS 6安装php加速软件Zend Guard(转)

    (尚未验证) PHP5.3以上的版本不再支持Zend Optimizer,已经被全新的 Zend Guard Loader 取代,下面是安装Zend Guard具体步骤,以下操作均在终端命令行执行 1 ...

  9. Linux下Moodle平台的快速安装方案

    一种快速安装与配置Moodle平台的方案,基本步骤: 1.选择与安装Linux系统 2.配置网络,开启shh和网络端口 3.一键安装集成环境(使用oneinstack方案) 4.服务器配置,端口和PH ...

  10. "WannaCry"勒索病毒用户处置指南

    "WannaCry"勒索病毒用户处置指南   原文: http://mp.weixin.qq.com/s/ExsribKum9-AN1ToT10Zog    卡巴斯基,下载官网:h ...