C Language / Lesson 5

C standard string functions

 
Include: <string.h>
Syntax: char *strcpy( char *dest, char *srce );
Returns: the destination string.
Description: copies from srce to dest until a NULL terminator is found
Include: <string.h>
Syntax: char *strchr( char *string, char c );
Returns: a pointer to the 1st occurrence of character c in string. If not successful then it returns NULL .
Description: searches for char c in NULL terminated string
Include: <string.h>
Syntax: int strcmp( char *string1, char *string2 );
Returns: a negative value if is less than , 0 if is equal to , or a positive value if is greater than .
Description: The strcmp function compares and and returns a value indicating their relationship, as follows: Value Meaning < 0 is less than = 0 is identical to > 0 is greater than The strcmp function operates on null-terminated strings. The arguments to this function are expected to contain a null character (\0) marking the end of the string.
Include: <string.h>
Syntax: char *strlwr( char *string );
char *strupr( char *string );
Returns: a pointer to the converted string.
Description: The strlwr function converts any uppercase letters in the given null-terminated string to lowercase. The strupr function converts any lowercase letters to uppercase. Other characters are not affected.
Include: <string.h>
Syntax: char *strcat( char *string1, char *string2 );
Returns: a pointer to the concatenated string.
Description: The strcat function operates on null-terminated strings.

 

Back to Index or to Previous Page or to Next Page