STRING :
String is an array of characters. A constant string is a group of characters defined between double quotation marks.
Ex.: char name[20];
The header file string.h is collection of string library functions.
String Related Library Function:
1. strlen()
2. strrev()
3. strcpy()
4. Strcat()
5. Strcmp()
Note : %s is used to read character at a time & then print it. We can also used the %c but it is cannot helpful to read the character or string to read & print at a time
1) strlen() -
This is a standard library function used to calculate the string length.
The syntax are as follows :
i = strlen(string);
‘i’ is a integer variable
2) strrev() –
This function is used to reverse the given string.
The syntax are as follows :
strrev(string);
3) strcpy() -
This function is to copy one string to another. It takes two arguments.
strcpy(str1,str2);
4) Strcat() -
String concatenation is used to join two strings.
Syntax :
strcat(string1, string 2);
5) Strcmp() –
String Compare function compares two strings with each other. If two strings are equal then function returns 0, else the difference between two strings.
Syntax:
strcmp(string1, string2);
0 comments:
Post a Comment