NAME
string, strcat, strncat, strchr, strrchr, strcmp, strncmp,
strcasecmp, strncasecmp, strcoll, strcpy, strncpy, strdup,
strlen,
strpbrk, strsep, strspn, strcspn, strtok, strxfrm, index,
rindex -
string operations
SYNOPSIS
#include <strings.h>
char *strcat(s, append)
char *s; const char *append;
char *strncat(s, append, count)
char *s; const char *append;
size_t count;
char *strchr(s, c)
const char *s;
int c;
char *strrchr(s, c)
const char *s;
int c;
strcmp(s1, s2)
const char *s1, *s2;
strncmp(s1, s2, count)
const char *s1, *s2;
size_t count;
strcasecmp(s1, s2)
const char *s1, *s2;
strncasecmp(s1, s2, count)
const char *s1, *s2;
size_t count;
char *strcoll(s1, s2)
const char *s1, *s2;
char *strcpy(to, from)
char *to; const char *from;
char *strncpy(to, from, count)
char *to; const char *from;
size_t count;
char *strdup(s)
const char *s;
strlen(s)
const char *s;
char *strpbrk(s, charset)
const char *s, charset;
int strsep(stringp, delim)
char **stringp; const char *delim;
size_t strspn(s, charset)
const char *s, *charset;
size_t strcspn(s, charset)
const char *s, *charset;
char *strstr(big, little)
const char *big, *little;
char *strtok(s, sep)
char *s; const char *sep;
size_t strxfrm(dst, src, n)
char *dst; const char *src;
size_t n;
char *index(s, c)
const char *s;
int c;
char *rindex(s, c)
const char *s;
int c;
DESCRIPTION
These functions operate on null-terminated strings. They do
not
check for overflow of any receiving string.
Strcat appends a copy of string
append to the end of string s.
Strncat copies at most count characters. Both return a
pointer to
the null-terminated result.
Strchr (strrchr) returns a
pointer to the first (last) occurrence
of c in the string s, or NULL if c does not occur anywhere
in s.
Setting c to NULL works.
Strcmp compares its arguments
and returns an integer greater than,
equal to, or less than 0, according as s1 is
lexicographically
greater than, equal to, or less than s2. Strncmp makes the
same
comparison but looks at at most count characters. Strcasecmp
and
strncasecmp are identical in function, but are case
insensitive.
The returned lexicographic difference reflects a conversion
to
lower-case.
Strcoll lexicographically
compares the null-terminated strings s1
and s2 according to the current locale collation and returns
an
integer greater than, equal to, or less than 0, according as
s1 is
greater than, equal to, or less than s2.
Strcpy copies string from to to,
stopping after the null character
has been moved. Strncpy copies exactly count characters,
appending
nulls if from is less than count characters in length; the
target
may not be null-terminated if the length of from is count or
more.
Both return to.
Strdup allocates sufficient
memory for a copy of the string s, does
the copy, and returns a pointer to it. The pointer may
subsequently be used as an argument to the function
free(3).
Strlen returns the number of non-null characters in s.
Strpbrk returns a pointer to the
first occurrence in string s of
any character in the string charset, or NULL if no
characters from
charset occur anywhere in s.
Strsep locates in the
null-terminated string *stringp the first
occurrence of any character in the string delim and replaces
this
with a ’ ’, records the location of the
immediately following
character in *stringp, then returns the original value of
*stringp.
If no delimiter characters are found, strsep set *stringp to
NULL;
if *stringp is initially NULL, strsep returns NULL.
Strspn (Strcspn) returns the
number of initial characters in s
which also occur (do not occur) in charset.
Strstr locates the first
occurrence of the null-terminated string
little in the null-terminated string big. If little is the
empty
string, strstr returns big; if little occurs nowhere in big,
strsep
returns NULL; otherwise strsep returns a pointer to the
first
character of the first occurrence of little.
Strtok is used to isolate
sequential tokens in the string s. These
tokens are separated in the string by one or more of the
characters
in sep. The first time that strtok is called, str should be
specified; subsequent calls, wishing to obtain further
tokens from
the same string, should pass a null pointer instead. The
separator
string, sep, must be supplied each time, and may change
between
calls. Strtok returns a pointer to the start of each
subsequent
token in the string, after replacing the token itself with a
NUL
character. When no more tokens remain, a null pointer is
returned.
Strxfrm does something horrible
(see the ANSI standard). In this
implementation it just copies.
Index (rindex) performs the same
function as strchr (strchr), just
under a different name.
SEE ALSO
malloc(3), free(3)