The <string.h>
header file declares one type and
several functions, and defines one macro useful for manipulating
character arrays that other objects treat as character arrays.
There are two kinds of string functions declared. The first, with
names beginning with str
, manipulate character
arrays; the second, with names beginning with mem
,
manipulate other objects treated as character arrays. Except for
memmove
, function behavior is undefined if copying
takes place between overlapping objects.
size_t
sizeof
operator.
NULL
void *memcpy(void *s1, const void *s2, size_
t n);
void *memmove(void *s1, const void *s2,
size_t n);
memmove
function
returns s1.
void *memchr(const void *s, int c, size_t
n);
char
) in the first n
unsigned characters of the object pointed to by s. The
memchr
function returns a pointer to the located
character, or a null pointer if the character was not found.
int memcmp(const void *s1, const void *s2,
size_t n);
memcmp
function returns an integer less than, equal to, or greater than
0, depending on whether the object pointed to by s1 is
less than, equal to, or greater than the object pointed to by
s2.
void *memset(void *s, int c, size_t
n);
char *strcpy(char *s1, const char
*s2);
strcpy
function returns
s1.
char *strncpy(char *s1, const char *s2,
size_t n);
strncpy
pads the copy with null
characters.
char *strcat(char *s1, const char
*s2);
strcat
function returns s1. The first character of s2
overwrites the null character of s1.
char *strncat(char *s1, const char *s2,
size_t n);
strncat
function returns s1. The first
character of s2 overwrites the null character of
s1. A terminating null character is appended to the
result. The first character of s2 overwrites the null
character of s1.
int strcmp(const char *s1, const char
*s2);
strcmp
function
returns an integer less than, equal to, or greater than 0,
depending on whether the string pointed to by s1 is
less than, equal to, or greater than the string pointed to by
s2.
int strcoll(const char *s1, const char
*s2);
LC_COLLATE
category of the current locale (see Section 9.5). The strcoll
function returns an integer less than, equal to, or greater than
0, depending on whether the string pointed to by s1
is less than, equal to, or greater than the string pointed to
by s2, when both are interpreted as appropriate to the
current locale.
int strncmp(const char *s1, const char *s2,
size_t n);
strncmp
function returns an integer less than, equal
to, or greater than 0, depending on whether the string pointed to
by s1 is less than, equal to, or greater than the string
pointed to by s2.
size_t strxfrm(char *s1, const char *s2,
size_t n);
See your DEC C library routine documentation for a detailed description of this function.
char *strchr(const char *s, int c);
char
) in the string pointed to by s.
The terminating null character is considered to be part of the
string. The function returns a pointer to the located character,
or a null pointer if the character was not found.
size_t strcspn(const char *s1, const char
*s2);
strcspn
function returns the length of the segment.
char *strpbrk(const char *s1, const char
*s2);
char *strrchr(const char *s, int c);
char
) in the string pointed to by s.
The terminating null character is considered to be part of the
string. The function returns a pointer to the located character,
or a null pointer if the character was not found.
size_t strspn(const char *s1, const char
*s2);
strspn
function returns the length of the segment.
char *strstr(const char *s1, const char
*s2);
strstr
function returns a pointer to the located
string, or a null pointer if the string was not found. If
s2 points to a string of zero length, the function
returns s1.
char *strtok(const char *s1, char
*s2);
strtok
() skips characters, looking for the first
one that is not in s2. The function keeps track of
its position in the string pointed to by s1 between
calls and, as successive calls are made, the function works
through this string, identifying the text token following the
one identified by the previous call. When the function finds a
character in s1 that matches a character in s2,
it replaces the character in s1 with a null character.
The strtok
function returns a pointer to the first
character of the token, or a null pointer if there is no token.
char *strerror(int errnum);
errnum
to an error
message string; returns a pointer to the string. The string
pointed to must not be modified by the program, but can be
overwritten by a subsequent call to strerror
.
size_t strlen(const char *s);