string.h C Library Functions

The string.h header file includes C standard library functions for string manipulation like copy, search, append, compare, splitting a string etc.

List of string.h Library Functions

Click on function names below to see detailed description of functions.

Function Description
memchr It searches for first occurence of a character in memory location.
memcmp It compares the first n bytes of two memory blocks.
memcpy It copies the first n bytes from one memory block to another.
memmove It moves the first n bytes from one memory block to another considering overlap.
memset It copies the character c to the first n bytes of the block of memory.
strcat It appends one string at the end of another string.
strchr It searches for the first occurrence of a character in the string.
strcmp It compares two strings character by character.
strncmp It compares first n characters of two strings.
strcpy It copies characters from one string into another string.
strncpy It copies first n characters from one string into another string.
strcspn It calculates the length of prefix of a string which doesn’t contain any character of another string.
strlen It returns the length of a string.
strncat It appends first n characters of one string at the end of another string.
strpbrk It searches for the first occurrence of any character of a string in another string.
strrchr It searches for the last occurrence of a character in the string.
strspn It returns the length of the initial segment of a string which consists entirely of characters in another string.
strstr It searches for the first occurrence of a string in another string.
strtok It breaks a string into smaller tokens.

Variable type in string.h Library

Type Description
size_t This is unsigned integral type

Macros in string.h Library

Macro Description
NULL Null pointer constant