1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" Modified Sun Jul 25 10:54:31 1993, Rik Faith (faith@cs.unc.edu)
10 .TH STRING 3 2021-03-22 "" "Linux Programmer's Manual"
12 stpcpy, strcasecmp, strcat, strchr, strcmp, strcoll, strcpy, strcspn,
13 strdup, strfry, strlen, strncat, strncmp, strncpy, strncasecmp, strpbrk,
14 strrchr, strsep, strspn, strstr, strtok, strxfrm, index, rindex
18 .RI ( libc ", " \-lc )
20 .B #include <strings.h>
22 .BI "int strcasecmp(const char *" s1 ", const char *" s2 );
29 .BI "int strncasecmp(const char *" s1 ", const char *" s2 ", size_t " n );
38 .BI "char *index(const char *" s ", int " c );
39 Return a pointer to the first occurrence of the character
44 .BI "char *rindex(const char *" s ", int " c );
45 Return a pointer to the last occurrence of the character
50 .B #include <string.h>
52 .BI "char *stpcpy(char *restrict " dest ", const char *restrict " src );
57 returning a pointer to the end of the resulting string at
60 .BI "char *strcat(char *restrict " dest ", const char *restrict " src );
68 .BI "char *strchr(const char *" s ", int " c );
69 Return a pointer to the first occurrence of the character
74 .BI "int strcmp(const char *" s1 ", const char *" s2 );
80 .BI "int strcoll(const char *" s1 ", const char *" s2 );
85 using the current locale.
87 .BI "char *strcpy(char *restrict " dest ", const char *restrict " src );
92 returning a pointer to the start of
95 .BI "size_t strcspn(const char *" s ", const char *" reject );
96 Calculate the length of the initial segment of the string
98 which does not contain any of bytes in the string
101 .BI "char *strdup(const char *" s );
102 Return a duplicate of the string
104 in memory allocated using
107 .BI "char *strfry(char *" string );
108 Randomly swap the characters in
111 .BI "size_t strlen(const char *" s );
112 Return the length of the string
115 .BI "char *strncat(char *restrict " dest ", const char *restrict " src \
119 bytes from the string
123 returning a pointer to
126 .BI "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n );
134 .BI "char *strncpy(char *restrict " dest ", const char *restrict " src \
142 returning a pointer to the start of
145 .BI "char *strpbrk(const char *" s ", const char *" accept );
146 Return a pointer to the first occurrence in the string
148 of one of the bytes in the string
151 .BI "char *strrchr(const char *" s ", int " c );
152 Return a pointer to the last occurrence of the character
157 .BI "char *strsep(char **restrict " stringp ", const char *restrict " delim );
158 Extract the initial token in
160 that is delimited by one of the bytes in
163 .BI "size_t strspn(const char *" s ", const char *" accept );
164 Calculate the length of the starting segment in the string
166 that consists entirely of bytes in
169 .BI "char *strstr(const char *" haystack ", const char *" needle );
170 Find the first occurrence of the substring
174 returning a pointer to the found substring.
176 .BI "char *strtok(char *restrict " s ", const char *restrict " delim );
177 Extract tokens from the string
179 that are delimited by one of the bytes in
182 .BI "size_t strxfrm(char *restrict " dst ", const char *restrict " src \
186 to the current locale and copies the first
191 The string functions perform operations on null-terminated
193 See the individual man pages for descriptions of each function.