C++ Standard Library C++ STL Library

C++ - <cstring> (string.h)



The C++ has a number of functions and macros that are available to work with C strings and arrays. These functions are available to use in a current program after including the header file using - #include <cstring> or #include <string.h>. All functions and macros of this header file are listed below:

Library Functions

Copy Functions

FunctionsDescription
memcpy() Copy block of memory.
memmove() Move block of memory.
strcpy() Copy string.
strncpy() Copy characters from string.

Comparison Functions

FunctionsDescription
memcmp() Compares two blocks of memory.
strcmp() Compares two strings.
strcoll() Compares two strings using locale.
strncmp() Compare characters of two strings.
strxfrm() Transform string using locale.

Concatenation Functions

FunctionsDescription
strcat() Concatenate strings.
strncat() Append characters from string.

Searching Functions

FunctionsDescription
memchr() Locate character in block of memory.
strchr() Searches the first occurrence of a character in a string.
strcspn() Get span until character in string.
strpbrk() Searches the first occurrence of any character of a string inside another string.
strrchr() Searches the last occurrence of a character in a string.
strspn() Get span of character set in string.
strstr() Searches the first occurrence of a string inside another string.
strtok() Split string into tokens.

Other Functions

FunctionsDescription
memset() Fills a block of memory.
strerror() Gets pointer to error message string.
strlen() Returns the length of a byte string.

Library Macros

Macro constants

MacrosDescription
NULL Null pointer.

Library Types

TypesDescription
size_t Unsigned integer type.