Namespaces
Variants
Views
Actions

Standard library header <cstring>

From cppreference.com
< cpp‎ | header
 
 
Standard library headers
Language support
Concepts
<concepts> (C++20)
Diagnostics
<system_error> (C++11)

Memory management
<memory_resource> (C++17)  
Metaprogramming
<type_traits> (C++11)
<ratio> (C++11)
General utilities
<utility>
<tuple> (C++11)
<optional> (C++17)
<variant> (C++17)
<any> (C++17)
<debugging> (C++26)
<expected> (C++23)
<bitset>
<charconv> (C++17)
<format> (C++20)
<bit> (C++20)

Strings
<cstring>
<cwchar>
<cuchar> (C++11)

Containers
<flat_set> (C++23)
<span> (C++20)
<mdspan> (C++23)

Iterators
<iterator>
Ranges
<ranges> (C++20)
<generator> (C++23)
Algorithms
Numerics
<cfenv> (C++11)
<complex>
<cmath>
<linalg> (C++26)
<numbers> (C++20)

Time
<chrono> (C++11)
Localization
<codecvt> (C++11/17/26*)
<text_encoding> (C++26)
Input/output
<filesystem> (C++17)
<cstdio>
<cinttypes> (C++11)
<strstream> (C++98/26*)
Regular expressions
<regex> (C++11)
Concurrency support
<stop_token> (C++20)
<thread> (C++11)
<atomic> (C++11)
<rcu> (C++26)
<stdatomic.h> (C++23)
<mutex> (C++11)
<shared_mutex> (C++14)

<condition_variable> (C++11)  
<semaphore> (C++20)
<latch> (C++20)

<barrier> (C++20)
<future> (C++11)
<hazard_pointer> (C++26)

C compatibility
<cstdbool> (C++11/17/20*)  
<ccomplex> (C++11/17/20*)
<ctgmath> (C++11/17/20*)

<cstdalign> (C++11/17/20*)

<ciso646> (until C++20)

 

This header was originally in the C standard library as <string.h>.

This header is for C-style null-terminated byte strings.

Contents

[edit] Macros

implementation-defined null pointer constant
(macro constant) [edit]

[edit] Types

unsigned integer type returned by the sizeof operator
(typedef) [edit]

[edit] Functions

String manipulation
copies one string to another
(function) [edit]
copies a certain amount of characters from one string to another
(function) [edit]
concatenates two strings
(function) [edit]
concatenates a certain amount of characters of two strings
(function) [edit]
transform a string so that strcmp would produce the same result as strcoll
(function) [edit]
String examination
returns the length of a given string
(function) [edit]
compares two strings
(function) [edit]
compares a certain number of characters from two strings
(function) [edit]
compares two strings in accordance to the current locale
(function) [edit]
finds the first occurrence of a character
(function) [edit]
finds the last occurrence of a character
(function) [edit]
returns the length of the maximum initial segment that consists
of only the characters found in another byte string
(function) [edit]
returns the length of the maximum initial segment that consists
of only the characters not found in another byte string
(function) [edit]
finds the first location of any character from a set of separators
(function) [edit]
finds the first occurrence of a substring of characters
(function) [edit]
finds the next token in a byte string
(function) [edit]
Character array manipulation
searches an array for the first occurrence of a character
(function) [edit]
compares two buffers
(function) [edit]
fills a buffer with a character
(function) [edit]
copies one buffer to another
(function) [edit]
moves one buffer to another
(function) [edit]
Miscellaneous
returns a text version of a given error code
(function) [edit]

[edit] Notes

[edit] Synopsis

namespace std {
  using size_t = /* see description */;                  // freestanding
 
  void* memcpy(void* s1, const void* s2, size_t n);      // freestanding
  void* memmove(void* s1, const void* s2, size_t n);     // freestanding
  char* strcpy(char* s1, const char* s2);                // freestanding
  char* strncpy(char* s1, const char* s2, size_t n);     // freestanding
  char* strcat(char* s1, const char* s2);                // freestanding
  char* strncat(char* s1, const char* s2, size_t n);     // freestanding
  int memcmp(const void* s1, const void* s2, size_t n);  // freestanding
  int strcmp(const char* s1, const char* s2);            // freestanding
  int 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
  void* memchr(void* s, int c, size_t n);                // freestanding
  const char* strchr(const char* s, int c);              // freestanding
  char* strchr(char* s, int c);                          // freestanding
  size_t strcspn(const char* s1, const char* s2);        // freestanding
  const char* strpbrk(const char* s1, const char* s2);   // freestanding
  char* strpbrk(char* s1, const char* s2);               // freestanding
  const char* strrchr(const char* s, int c);             // freestanding
  char* strrchr(char* s, int c);                         // freestanding
  size_t strspn(const char* s1, const char* s2);         // freestanding
  const char* strstr(const char* s1, const char* s2);    // freestanding
  char* strstr(char* s1, const char* s2);                // freestanding
  char* strtok(char* s1, const char* s2);                // freestanding
  void* memset(void* s, int c, size_t n);                // freestanding
  char* strerror(int errnum);
  size_t strlen(const char* s);                          // freestanding
}
 
#define NULL /* see description */                       // freestanding