Skip to content
Published at:

glibc实现

代码:https://www.gnu.org/software/libc/sources.html

string.h

字符串操作

  • strcpy 复制一个字符串给另一个
  • strncpy 从一个字符串复制一定数量的字符到另一个
  • strcat 连接两个字符串
  • strncat 连接两个字符串的一定数量字符
  • strxfrm transform a string so that strcmp would produce the same result as strcoll

字符串检验

  • strlen 返回给定字符串的长度
  • strcmp 比较两个字符串
  • strncmp 比较两个字符串的一定数量字符
  • strcoll compares two strings in accordance to the current locale
  • strchr 查找字符的首次出现
  • strrchr 查找字符的最后一次出现
  • strspn returns the length of the maximum initial segment that consists of only the characters found in another byte string
  • strcspn returns the length of the maximum initial segment that consists of only the characters not found in another byte string
  • strpbrk finds the first location of any character in one string, in another string
  • strstr 查找子串字符的首次出现
  • strtok 查找字节字符串中的下一个记号

字符数组操作

  • memchr 在数组中搜索字符的首次出现
  • memcmp 比较两块缓冲区
  • memset 以字符填充缓冲区
  • memcpy 将一个缓冲区复制到另一个
  • memmove 将一个缓冲区移动到另一个