Files
2025-10-25 03:02:53 +03:00

52 lines
4.5 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[cstring.syn]
# 27 Strings library [[strings]](./#strings)
## 27.5 Null-terminated sequence utilities [[c.strings]](c.strings#cstring.syn)
### 27.5.1 Header <cstring> synopsis [cstring.syn]
[🔗](#lib:memchr)
#define __STDC_VERSION_STRING_H__ 202311Lnamespace std {using size_t = *see [[support.types.layout]](support.types.layout "17.2.4Sizes, 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.2The C standard library")void* memchr(void* s, int c, size_t n); // freestanding; see [[library.c]](library.c "16.2The C standard library")const char* strchr(const char* s, int c); // freestanding; see [[library.c]](library.c "16.2The C standard library")char* strchr(char* s, int c); // freestanding; see [[library.c]](library.c "16.2The 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.2The C standard library")char* strpbrk(char* s1, const char* s2); // freestanding; see [[library.c]](library.c "16.2The C standard library")const char* strrchr(const char* s, int c); // freestanding; see [[library.c]](library.c "16.2The C standard library")char* strrchr(char* s, int c); // freestanding; see [[library.c]](library.c "16.2The 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.2The C standard library")char* strstr(char* s1, const char* s2); // freestanding; see [[library.c]](library.c "16.2The 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.3Null pointers")* // freestanding
[1](#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.1General[support.c.headers.general]")[.](#1.sentence-1)
[2](#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.10Data race avoidance[res.on.data.races]")[.](#2.sentence-1)
[3](#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.5Signal handlers[support.signal]")[.](#3.sentence-1)
Each of these functions implicitly creates objects ([[intro.object]](intro.object "6.8.2Object model"))
in the destination region of storage
immediately prior to copying the sequence of characters to the destination[.](#3.sentence-2)
Each of these functions returns a pointer to a suitable created object, if any,
otherwise the value of the first parameter[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5544)
[*Note [1](#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.2The C standard library[library.c]")[.](#4.sentence-1)
— *end note*]
See also: ISO/IEC 9899:2024, 7.26