Explain the various string operations with examples.
1. strupr() – This function converts a string to upper case. Syntax: strupr(str1);
Example : strupr(“mukesh rajput”)= MUKESH RAJPUT
2. strlwr() – This function converts a string to lower case. Syntax: strlwr(str1)
Example : strlwr(“CHANDIGARH”)=chandigarh
3. strlen() – This function returns the length of the string. The function returns the number of characters in the strings. Syntax: strlen(str1)
Example : strlen(“mukesh rajput”)=13
4. strcat()- This function concatenates(combines) two or more stings in to a single string. Syntax: strcat(str1,str2)
Example : x=”muk” y=”esh” strcat(x, y)=mukesh
5. strrev()- This function reverses the string. Syntax: strrev(str1)
Example : strrev(“mukesh”)=hsekum
6. strcpy()- This function copies a string to a variable. Syntax: strcpy(str1,str2)
Example : strcpy(x,”mukesh”) x =mukesh
7. strcmp()- This function compares the two strings and returns the ASCII difference between the two strings. This is case sensitive. Syntax: strcmp(str1,str2)
Example : strcmp(“their”,”there”)=-9
8. strcmpi()- This function compares specified number of characters from both the strings and returns a value. This function is case insensitive.
Example : strcmpi(“There”,”there”)=0
Thanks
Mukesh Rajput
Post A Comment:
0 comments: