Published by: Nuru
Published date: 21 Jun 2021
String Library Functions are those functions in C, which has some useful contribution for functioning and working of the strings. Some of the string handling functions are strcpy ( ), strcmp ( ), strlen ( ), strcat ( ), etc.
Let us see the working of some of the string functions.
We use these library functions to manipulate the string data. One can call these functions from the header file namely string.h file.
Some of the string functions are briefly discussed below:
We use strcpy ( ) function is used to copy the one string into another one. Another function strncpy ( ) is used for the copying of one part of the string to the other.
The following given program can illustrate the use of the copying string.
Output:
The length of the string is the number of characters present in the string excluding the null character. To find the length of the given string, we use strlen ( ) function.
Syntax: integer_variable = strlen (input_string);
Let us see a program for it:
Ouput:
We already know that there is the use of string function strcat ( ) for concatenating two strings. It links or joins the two strings together.
For Instance, let us see a program below:
Output:
Like other functions, for the conversion of string from lower to upper case, there is a library function that is strupr ( ). This converts the given lower case string to the upper case.
For Instance:
Output:
The process of conversion to lowercase is also the same method. But, the library function we use here is, strlwr ( ). It converts the uppercase string into the lower case.
For Example:
Output:
These are some of the library functions of String variables.