[c.strings]

# 27 Strings library [[strings]](./#strings)

## 27.5 Null-terminated sequence utilities [c.strings]

### [27.5.1](#cstring.syn) Header <cstring> synopsis [[cstring.syn]](cstring.syn)

[ð](#lib:memchr)

#define __STDC_VERSION_STRING_H__ 202311Lnamespace std {using size_t = *see [[support.types.layout]](support.types.layout "17.2.4 Sizes, alignments, and offsets")*; // freestandingvoid* memcpy(void* s1, const void* s2, size_t n); // freestandingvoid* memccpy(void* s1, const void* s2, int c, size_t n); // freestandingvoid* memmove(void* s1, const void* s2, size_t n); // freestandingchar* strcpy(char* s1, const char* s2); // freestandingchar* strncpy(char* s1, const char* s2, size_t n); // freestandingchar* strdup(const char* s); char* strndup(const char* s, size_t size); char* strcat(char* s1, const char* s2); // freestandingchar* strncat(char* s1, const char* s2, size_t n); // freestandingint memcmp(const void* s1, const void* s2, size_t n); // freestandingint strcmp(const char* s1, const char* s2); // freestandingint strcoll(const char* s1, const char* s2); int strncmp(const char* s1, const char* s2, size_t n); // freestanding size_t strxfrm(char* s1, const char* s2, size_t n); const void* memchr(const void* s, int c, size_t n); // freestanding; see [[library.c]](library.c "16.2 The C standard library")void* memchr(void* s, int c, size_t n); // freestanding; see [[library.c]](library.c "16.2 The C standard library")const char* strchr(const char* s, int c); // freestanding; see [[library.c]](library.c "16.2 The C standard library")char* strchr(char* s, int c); // freestanding; see [[library.c]](library.c "16.2 The C standard library") size_t strcspn(const char* s1, const char* s2); // freestandingconst char* strpbrk(const char* s1, const char* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")char* strpbrk(char* s1, const char* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")const char* strrchr(const char* s, int c); // freestanding; see [[library.c]](library.c "16.2 The C standard library")char* strrchr(char* s, int c); // freestanding; see [[library.c]](library.c "16.2 The C standard library") size_t strspn(const char* s1, const char* s2); // freestandingconst char* strstr(const char* s1, const char* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")char* strstr(char* s1, const char* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")char* strtok(char* s1, const char* s2); void* memset(void* s, int c, size_t n); // freestandingvoid* memset_explicit(void* s, int c, size_t n); // freestandingchar* strerror(int errnum);
 size_t strlen(const char* s); // freestanding}#define NULL *see [[support.types.nullptr]](support.types.nullptr "17.2.3 Null pointers")* // freestanding

[1](#cstring.syn-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5526)

The contents and meaning of the header <cstring> are the same as the C standard library header [<string.h>](support.c.headers.general#header:%3cstring.h%3e "17.15.1 General [support.c.headers.general]")[.](#cstring.syn-1.sentence-1)

[2](#cstring.syn-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5530)

The functions strerror and strtok are not required to[avoid data races](res.on.data.races "16.4.6.10 Data race avoidance [res.on.data.races]")[.](#cstring.syn-2.sentence-1)

[3](#cstring.syn-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5534)

The functions memcpy and memmove are [signal-safe](support.signal#def:evaluation,signal-safe "17.14.5 Signal handlers [support.signal]")[.](#cstring.syn-3.sentence-1)

Each of these functions implicitly creates objects ([[intro.object]](intro.object "6.8.2 Object model"))
in the destination region of storage
immediately prior to copying the sequence of characters to the destination[.](#cstring.syn-3.sentence-2)

Each of these functions returns a pointer to a suitable created object, if any,
otherwise the value of the first parameter[.](#cstring.syn-3.sentence-3)

[4](#cstring.syn-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5544)

[*Note [1](#cstring.syn-note-1)*:

The functionsstrchr, strpbrk, strrchr, strstr, and memchr,
have different signatures in this document,
but they have the same behavior as in the [C standard library](library.c "16.2 The C standard library [library.c]")[.](#cstring.syn-4.sentence-1)

â *end note*]

See also: ISO/IEC 9899:2024, 7.26
