String.h

String Manipulations In C Programming Using Library Functions


Strings are often needed to be manipulated by programmer according to the need of a problem. All string manipulation can be done manually by the programmer but, this makes programming complex and large. To solve this, the C supports a large number of string handling functions.
Strings handling functions are defined under "string.h" header file, i.e, you have to include the code below to run string handling functions.
#include <lstring.h>


string handling functions


Copying:

Function Name ReturnWhat They Do
memcpy destination

Copy block of memory

memmove destination

Move block of memory

strcpy destination

Copies one string into another

strncpy destination

Copy characters from string


Concatenation:

Function Name ReturnWhat They Do
strcat destination

Concatenate strings

strncat destination

Append characters from string


Comparison:

Function Name ReturnWhat They Do
memcmp integral value

Compare two blocks of memory

strcmp integral value

Compare two strings

strcoll integral value

Compare two strings using locale

strncmp integal value

Compare characters of two strings

strxfrm length of transformed string, excluding terminating character

Transform string using locale


Searching:

Function Name Return What They Do
memchr A pointer to the first occurrence of value in the block of memory pointer by pointer variable

Locate character in block of memory

strchr A pointer to first occurance of character in a string

Locate first occurrence of character in string

strcspn Length of the initial part of String not containing any of the characters that are part of another String

Get span until character in string

strpbrk A pointer to first occurance of any of character of string 2 in string 1

Locate character in string

strrchr A pointer to last occurance of character in String

Locate last occurrence of character in string

strspn Length of initial part of string1 containing only characters that is present in String2

Get span of character set in string

strstr A pointer to last occurance of character in a String

Locate substring

strtok A pointer to last token found in a String

Split string into tokens


Other:

Function Name ReturnWhat They Do
memset A pointer is returned

Fill block of memory

strerror A pointer to generated message String

Get pointer to error message string

strlen Length of String

Get string length