The header file <string.h> defines functions that operate on arrays that are interpreted as null-terminated strings.
Various methods are used for determining the lengths of the arrays, but in all cases a char * or void * argument points to the initial (lowest addressed) character of the array. If an array is accessed beyond the end of an object, the behavior is undefined.
Where an argument declared as size_t n specifies the length of an array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function, pointer arguments must have valid values on a call with a zero size. On such a call, a function that locates a character finds no occurrence, a function that compares two character sequences returns zero, and a function that copies characters copies zero characters.
Copying functions | |
memcpy | Copy memory |
memmove | Safely copy overlapping memory |
strcpy | Copy string |
strncpy | Copy string up to a maximum length |
Concatenation functions | |
strcat | Convert string to int |
strncat | Convert string to long |
Comparison functions | |
memcmp | Compare memory |
strcmp | Compare strings |
strncmp | Compare strings up to a maximum length |
strcoll | Collate strings |
Search functions | |
memchr | Search memory for a character |
strchr | Find first occurrence of character within string |
strcspn | Compute size of string not prefixed by a set of characters |
strpbrk | Find first occurrence of characters within string |
strrchr | Find last occurrence of character within string |
strspn | Compute size of string prefixed by a set of characters |
strstr | Find first occurrence of a string within a string |
strtok | Break string into tokens |
Miscellaneous functions | |
memset | Set memory to character |
strerror | Return string from error code |
strlen | Calculate length of string |