Flash cards
Review the key moves
What is the main idea behind C++ cstring Library?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Put the learning moves in the order that makes the concept easiest to apply.
C++ cstring Functions
The <cstring> library has many functions that allow you to perform tasks on arrays and C-style strings.
Note that C-style strings are different than regular strings . A C-style string is an array of characters, created with the char type. To learn more about C-style strings, read our C Strings Tutorial .
A list of all cstring functions can be found in the table below.
| Function | Description |
|---|---|
| memchr() | Returns a pointer to the first occurrence of a value in a block of memory |
| memcmp() | Compares two blocks of memory to determine which one represents a larger numeric value |
| memcpy() | Copies data from one block of memory to another |
| memmove() | Copies data from one block of memory to another accounting for the possibility that the blocks of memory overlap |
| memset() | Sets all of the bytes in a block of memory to the same value |
| strcat() | Appends one C-style string to the end of another |
| strchr() | Returns a pointer to the first occurrence of a character in a C-style string |
| strcmp() | Compares the ASCII values of characters in two C-style strings to determine which string has a higher value |
| strcoll() | Compares the locale-based values of characters in two C-style strings to determine which string has a higher value |
| strcpy() | Copies the characters of a C-style string into the memory of another string |
| strcspn() | Returns the length of a C-style string up to the first occurrence of one of the specified characters |
| strerror() | Returns a C-style string describing the meaning of an error code |
| strlen() | Return the length of a C-style string |
| strncat() | Appends a number of characters from a C-style string to the end of another string |
| strncmp() | Compares the ASCII values of a specified number of characters in two C-style strings to determine which string has a higher value |
| strncpy() | Copies a number of characters from one C-style string into the memory of another string |
| strpbrk() | Returns a pointer to the first position in a C-style string which contains one of the specified characters |
| strrchr() | Returns a pointer to the last occurrence of a character in a C-style string |
| strspn() | Returns the length of a C-style string up to the first character which is not one of the specified characters |
| strstr() | Returns a pointer to the first occurrence of a C-style string in another string |
| strtok() | Splits a string into pieces using delimiters |
| strxfrm() | Convert characters in a C-style string from ASCII encoding to the encoding of the current locale |
Learn more about c-style strings in our C-Style Strings Tutorial .