string.3c (2010 09)
s
string(3C) string(3C)
NAME
string: strcasecmp(), strcat(), strchr(), strcmp(), strcoll(), strcpy(), strcspn(), strdup(), strlen(),
strncasecmp(), strncat(), strncmp(), strncpy(), strpbrk(), strrchr(), strrstr(), strspn(), strstr(), strtok(),
strtok_r(), strxfrm(), index(), rindex() - character string operations
SYNOPSIS
#include <string.h>
#include <strings.h>
char *strcat(char *__restrict s1, const char *__restrict s2);
char *strncat(char *__restrict s1, const char *__restrict s2, size_t n);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
int strcasecmp(const char *s1, const char *s2);
int strncasecmp(const char *s1, const char *s2, size_t n);
char *strcpy(char *__restrict s1, const char *__restrict s2);
char *strncpy(char *__restrict s1, const char *__restrict s2, size_t n);
char *strdup(const char *s);
size_t strlen(const char *s);
char *strchr(const char *s, int c);
char *strrchr(const char *s, int c);
char *strpbrk(const char *s1, const char *s2);
size_t strspn(const char *s1, const char *s2);
size_t strcspn(const char *s1, const char *s2);
char *strstr(const char *s1, const char *s2);
char *strrstr(const char *s1, const char *s2);
char *strtok(char *__restrict s1, const char *__restrict s2);
char *strtok_r(char *s1, const char *s2, char **last);
int strcoll(const char *s1, const char *s2);
size_t strxfrm(char *__restrict s1, const char *__restrict s2, size_t n);
char *index(const char *s, int c);
char *rindex(const char *s, int c);
Remarks
All functions except index() and rindex() are declared in both headers, so only one of the two
headers needs to be included.
The functions
index() and rindex() are declared only in <strings.h>. They are provided solely
for portability of BSD applications, and are not recommended for new applications where portability is
important. For portable applications, use <string.h>, strchr(), and strrchr() instead.
DESCRIPTION
Arguments s1, s2, and s point to strings (arrays of characters terminated by a null byte).
Definitions for all these functions, the type size_t, and the constant NULL are provided in the
<string.h>header.
strcat() Appends a copy of string s2 to the end of string s1. strncat() appends a maximum
of n characters. It copies fewer if s2 is shorter than n characters. Each returns a pointer
to the null-terminated result (the value of s1).
strcmp() Compares its arguments and returns an integer less than, equal to, or greater than zero,
depending on whether s1 is lexicographically less than, equal to, or greater than s2. The
comparison of corresponding characters is done as if the type of the characters were
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1