What are string handling functions?

String handling functions:

1.      strlen(): This function tells the number of character in a string. This will be as follows: l=strlen(string);

where l is integer.

2.      strcat():  This function is use to combine two strings. This will be as follows:

strcat(string1,string2);

in this function the string2 is appended to string1 and it removes the ‘’ from string1.

3.      strcpy(): This function is use to copy the contents of string to another. This will be as follows:

strcpy(string1,string2);

this will copy the content of string2 to string1. And we can give string constant instead of character array.

e.g: strcpy(subject,”programming in c”);

4.      strcmp(): This function is use to compare two strings. This will be as follows:

strcmp(string1,string2);

this will compare the both strings. And if they are equal this will return 0. Otherwise it will returns the numeric difference in both according to ASCII values.

Leave a Reply

Your email address will not be published. Required fields are marked *