#include <string.h>
(for C++ and namespace std, #include
<cstring>)
*note: size_t is generally defined
as an unsigned short.
char *strcpy( char *s1, const char *s2)
copies the string s2 into the character array s1. The value of s1 is returned.
char *strncpy( char *s1, const char *s2, size_t n)
copies at most n characters of the string s2 into the character array s1. The value of s1 is returned.
char *strcat( char *s1, const char *s2)
appends the string s2 to the end of character array s1. The first character from s2 overwrites the '\0' of s1. The value of s1 is returned.
char *strncat( char *s1, const char *s2, size_t n)
appends at most n characters of the string s2 to the end of character array s1. The first character from s2 overwrites the '\0' of s1. The value of s1 is returned.
char *strchr( const char *s, int c)
returns a pointer to the first instance of c in s. Returns a NULL pointer if c is not encountered in the string.
char *strrchr( const char *s, int c)
returns a pointer to the last instance of c in s. Returns a NULL pointer if c is not encountered in the string.
int strcmp( const char *s1, const char *s2)
compares the string s1 to the string s2. The function returns 0 if they are the same, a number < 0 if s1 < s2, a number > 0 if s1 > s2.
int strncmp( const char *s1, const char *s2, size_t n)
compares up to n characters of the string s1 to the string s2. The function returns 0 if they are the same, a number < 0 ifs1 < s2, a number > 0 if s1 > s2.
size_t strspn( char *s1, const char *s2)
returns the length of the longest substring of s1 that begins at the start of s1and consists only of the characters found in s2.
size_t strcspn( char *s1, const char *s2)
returns the length of the longest substring of s1 that begins at the start of s1and contains none of the characters found in s2.
size_t strlen( const char *s)
determines the length of the string s. Returns the number of characters in the string before the '\0'.
char *strpbrk( const char *s1, const char *s2)
returns a pointer to the first instance in s1 of any character found in s2. Returns a NULL pointer if no characters from s2 are encountered in s1.
char *strstr( const char *s1, const char *s2)
returns a pointer to the first instance of string s2 in s1. Returns a NULL pointer if s2 is not encountered in s1.
char *strtok(char *s1, const char *s2)
repeated calls to this function break string s1 into "tokens"--that is the string is broken into substrings, each terminating with a '\0', where the '\0' replaces any characters contained in string s2. The first call uses the string to be tokenized as s1; subsequent calls use NULL as the first argument. A pointer to the beginning of the current token is returned; NULL is returned if there are no more tokens.
Copyright©2001-2003 Edmonds Community College