C Programming - Old Questions
9. Discuss any five string library functions.
Five string library functions are given below:
1. strlen(): It returns the number of characters in a string.
syntax: strlen(string_name)
2. strcpy(): It copies the contents of source string to destination string.
syntax: strcpy(destination_string, source_string)
3. strcat(): It concats or joins first string with second string. The result of the string is stored in first string.
syntax: strcat(first_string, second_string)
4. strcmp(): It compares the first string with second string. If both strings are same, it returns 0.
syntax: strcmp(first_string, second_string)
5. strstr(): It is used to search whether a substring is present in the main string or not.
syntax: strstr(mainsring, substring)