C String Operations

The C programming language has a set of functions implementing operations on strings in its standard library string.h. Operations such as concatenations, copying, tokenization and sub-string search is supported.

List of commonly used string manipulation functions

Function Description
strcat Concatenates two string
strncat Appends not more than n characters of a string into another string
strcpy Copies one string into another string
strncpy Copies n characters of a string into another string
strcmp Compares two string. If the first string is lexographically less than the second, a value less than zero is returned. If the first is lexographically greater than the second, a value greater than zero is returned. And zero if the two strings are equal.
strlen Finds the length of the string (not considering the null byte)
strchr Returns a pointer to the first occurrence of a character in a string
strrchr Returns a pointer to the last occurrence of a character in a string
strstr Returns a pointer to the first occurrence of a string in a string
strrev Reverses the string
strupr Converts lowercase string to uppercase
strlwr Converts uppercase string to lowercase

Trending

C Programming

Remember to follow community guidelines and don't go off topic.