InterviewSolution
| 1. |
Write a note on string handling functions. |
|
Answer» 1. strlen( ) function: It calculates the length of the given string and returns the number of characters in a string. The length does not include the NULL character. Syntax: integer variable = strlen(string); 2. Strcpy( ) function: It copies the content of one string to another. The strcpy( ) function works almost like a string assignment operator. Syntax: strcpy(<string1>,<string2>); When strcpy( ) function is executed, it copies string2 to string1, String2 can be a character array or a character constant. 3. strcat() function: It adds the characters of one string to the end of another string. It is used to join two strings together. Syntax: strcat(string1, string2); The contents of string2 are added attend in string 1, where string 1 is the target string and string 2 is the source string. 4. strrev() function: It reverses the characters in a string. Syntax: strrev(string); eg: strrev(“ABCD”); Output: DCBA 5. strlwr() function: converts all characters in a string to lower (small letters) case. Syntax: strlwr(string); eg: strlwr(“BHARATH”) Output: bharath. |
|