Thursday 14 February 2013

Standard String - Handling Functions in C



A brief description of some of the standard string functions of C given below,

strcmp()

strcmp() compares 2 strings (its parameters) character by character (ASCII comparison) and returns any of the integer values. less than(), greater than().

strcpy()

strcpy() copies the second string to the first string named in the strcpy() parameters.

For example, the following statement:

strcpy (str1, "ABC");

will copy the string "ABC" to the array str1.

strcat()

strcat() appends the second string passed at the end of the first string passed to it.

For example:

strcat (str1, "ABC");

will add the string "ABC" to the contents of the array str1.

strlen()

This function returns the number of characters in the string passed to it. The length does not include the NULL character.

For example, if the array str1 contains the string "1234", then the following statement:

y = strlen(str1);

will cause y to have the value 4.

0 comments:

Post a Comment

Powered by Blogger.