Standard C Library – String.h Functions
The C language comes bundled with <string.h> which contains some useful string-handling functions. Some of them are as follows:
Function Name | Description |
---|---|
strlen(string_name) | Returns the length of string name. |
strcpy(s1, s2) | Copies the contents of string s2 to string s1. |
strcmp(str1, str2) | Compares the first string with the second string. If strings are the same it returns 0. |
strcat(s1, s2) | Concat s1 string with s2 string and the result is stored in the first string. |
strlwr() | Converts string to lowercase. |
strupr() | Converts string to uppercase. |
strstr(s1, s2) | Find the first occurrence of s2 in s1. |
Must Read:
Strings in C
A String in C programming is a sequence of characters terminated with a null character ‘\0’. The C String is stored as an array of characters. The difference between a character array and a C string is that the string in C is terminated with a unique character ‘\0’.