Standard library header <string.h> - cppreference.com (original) (raw)

This header provides functions for handling null-terminated byte strings.

[edit] Synopsis

#define STDC_VERSION_STRING_H 202311L   #define NULL /* see description /   typedef / see description / 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);

Only if the implementation defines __STDC_LIB_EXT1__ and additionally the user code defines__STDC_WANT_LIB_EXT1__ before any inclusion of <string.h>:

#ifdef STDC_WANT_LIB_EXT1   tyepdef /* see description / errno_t; tyepdef / see description / 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