标准库标头 <string.h>

来自cppreference.com
< c‎ | header


此标题提供了用于处理空终止字节字符串的函数。

实现定义的空指针常量
(宏常量)

类型

sizeof 运算符返回的无符号整数类型
(typedef)

函数

字符串操纵
复制字符串给另一个
(函数)
从字符串复制一定数量的字符到另一个
(函数)
连接两个字符串
(函数)
连接两个字符串的一定数量字符
(函数)
变换字符串,使得 strcmp 会产生同 strcoll 的结果
(函数)
(C23)
分配字符串的副本
(函数)
分配拥有指定大小的字符串副本
(函数)
字符串检验
返回给定字符串的长度
(函数)
比较两个字符串
(函数)
比较两个字符串的一定数量字符
(函数)
比较两个字符串,根据当前本地环境
(函数)
查找字符的首次出现
(函数)
查找字符的最后一次出现
(函数)
返回由另一个字符串中的字符分割的最大起始段长度
(函数)
返回另一个字符串所不具有的字符分割的最大起始段长度
(函数)
查找字符串中的任意字符在另一个字符串中的首个位置
(函数)
查找子串字符的首次出现
(函数)
查找字节字符串中的下一个记号
(函数)
字符数组操纵
在数组中搜索字符的首次出现
(函数)
比较两块缓冲区
(函数)
以字符填充缓冲区
(函数)
复制缓冲区到另一个
(函数)
移动缓冲区到另一个
(函数)
复制缓冲区到另一个,在指定的分隔符后停止
(函数)
杂项
返回给定错误码的文本版本
(函数)

概要

#define __STDC_VERSION_STRING_H__ 202311L
 
#define NULL /* 见描述 */
 
typedef /* 见描述 */ size_t;
 
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
void* memccpy(void* restrict s1, const void* restrict s2, int c, size_t n);
void* memmove(void* s1, const void* s2, size_t n);
char* strcpy(char* restrict s1, const char* restrict s2);
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
char* strdup(const char* s);
char* strndup(const char* s, size_t n);
char* strcat(char* restrict s1, const char* restrict s2);
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
int strcmp(const char* s1, const char* s2);
int strcoll(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
/*QVoid*/* memchr(/*QVoid*/* s, int c, size_t n);
/*QChar*/* strchr(/*QChar*/* s, int c);
size_t strcspn(const char* s1, const char* s2);
/*QChar*/* strpbrk(/*QChar*/* s1, const char* s2);
/*QChar*/* strrchr(/*QChar*/* s, int c);
size_t strspn(const char* s1, const char* s2);
/*QChar*/* strstr(/*QChar*/* s1, const char* s2);
char* strtok(char* restrict s1, const char* restrict s2);
void* memset(void* s, int c, size_t n);
void* memset_explicit(void* s, int c, size_t n);
char* strerror(int errnum);
size_t strlen(const char* s);
size_t strnlen(const char* s, size_t n);

仅当实现定义了 __STDC_LIB_EXT1__,并且用户代码在对 <string.h> 的所有包含之前定义了 __STDC_WANT_LIB_EXT1__

#ifdef __STDC_WANT_LIB_EXT1__
 
tyepdef /* 见描述 */ errno_t;
tyepdef /* 见描述 */ rsize_t;
 
errno_t memcpy_s(void* restrict s1, rsize_t s1max, const void* restrict s2, rsize_t n);
errno_t memmove_s(void* s1, rsize_t s1max, const void* s2, rsize_t n);
errno_t strcpy_s(char* restrict s1, rsize_t s1max, const char* restrict s2);
errno_t strncpy_s(char* restrict s1, rsize_t s1max, const char* restrict s2, rsize_t n);
errno_t strcat_s(char* restrict s1, rsize_t s1max, const char* restrict s2);
errno_t strncat_s(char* restrict s1, rsize_t s1max, const char* restrict s2, rsize_t n);
char* strtok_s(char* restrict s1, rsize_t* restrict s1max,
               const char* restrict s2, char** restrict ptr);
errno_t memset_s(void* s, rsize_t smax, int c, rsize_t n)
errno_t strerror_s(char* s, rsize_t maxsize, errno_t errnum);
size_t strerrorlen_s(errno_t errnum);
size_t strnlen_s(const char* s, size_t maxsize);
 
#endif