Standard library header <cstring>

From cppreference.com
< cpp‎ | header
 
 
Standard library headers
Algorithms
<algorithm>
<numeric>
Strings
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
Text processing
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
Numerics
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<valarray>
Time
<chrono> (C++11)
<ctime>
C compatibility
<ccomplex> (C++11/17/20*)
<ciso646> (until C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

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

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

Macros

implementation-defined null pointer constant
(macro constant)

Types

unsigned integer type returned by the sizeof operator
(typedef)

Functions

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

Notes

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