mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / string.3
blob228ca3d1852fe3d24eb91ee51c18d38937a4bc17
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sun Jul 25 10:54:31 1993, Rik Faith (faith@cs.unc.edu)
30 .TH STRING 3  2021-03-22 "" "Linux Programmer's Manual"
31 .SH NAME
32 stpcpy, strcasecmp, strcat, strchr, strcmp, strcoll, strcpy, strcspn,
33 strdup, strfry, strlen, strncat, strncmp, strncpy, strncasecmp, strpbrk,
34 strrchr, strsep, strspn, strstr, strtok, strxfrm, index, rindex
35 \- string operations
36 .SH SYNOPSIS
37 .B #include <strings.h>
38 .TP
39 .BI "int strcasecmp(const char *" s1 ", const char *" s2 );
40 Compare the strings
41 .I s1
42 and
43 .I s2
44 ignoring case.
45 .TP
46 .BI "int strncasecmp(const char *" s1 ", const char *" s2 ", size_t " n );
47 Compare the first
48 .I n
49 bytes of the strings
50 .I s1
51 and
52 .I s2
53 ignoring case.
54 .TP
55 .BI "char *index(const char *" s ", int " c );
56 Return a pointer to the first occurrence of the character
57 .I c
58 in the string
59 .IR s .
60 .TP
61 .BI "char *rindex(const char *" s ", int " c );
62 Return a pointer to the last occurrence of the character
63 .I c
64 in the string
65 .IR s .
66 .TP
67 .B #include <string.h>
68 .TP
69 .BI "char *stpcpy(char *restrict " dest ", const char *restrict " src );
70 Copy a string from
71 .I src
73 .IR dest ,
74 returning a pointer to the end of the resulting string at
75 .IR dest .
76 .TP
77 .BI "char *strcat(char *restrict " dest ", const char *restrict " src );
78 Append the string
79 .I src
80 to the string
81 .IR dest ,
82 returning a pointer
83 .IR dest .
84 .TP
85 .BI "char *strchr(const char *" s ", int " c );
86 Return a pointer to the first occurrence of the character
87 .I c
88 in the string
89 .IR s .
90 .TP
91 .BI "int strcmp(const char *" s1 ", const char *" s2 );
92 Compare the strings
93 .I s1
94 with
95 .IR s2 .
96 .TP
97 .BI "int strcoll(const char *" s1 ", const char *" s2 );
98 Compare the strings
99 .I s1
100 with
101 .I s2
102 using the current locale.
104 .BI "char *strcpy(char *restrict " dest ", const char *restrict " src );
105 Copy the string
106 .I src
108 .IR dest ,
109 returning a pointer to the start of
110 .IR dest .
112 .BI "size_t strcspn(const char *" s ", const char *" reject );
113 Calculate the length of the initial segment of the string
114 .I s
115 which does not contain any of bytes in the string
116 .IR reject ,
118 .BI "char *strdup(const char *" s );
119 Return a duplicate of the string
120 .I s
121 in memory allocated using
122 .BR malloc (3).
124 .BI "char *strfry(char *" string );
125 Randomly swap the characters in
126 .IR string .
128 .BI "size_t strlen(const char *" s );
129 Return the length of the string
130 .IR s .
132 .BI "char *strncat(char *restrict " dest ", const char *restrict " src \
133 ", size_t " n );
134 Append at most
135 .I n
136 bytes from the string
137 .I src
138 to the string
139 .IR dest ,
140 returning a pointer to
141 .IR dest .
143 .BI "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n );
144 Compare at most
145 .I n
146 bytes of the strings
147 .I s1
149 .IR s2 .
151 .BI "char *strncpy(char *restrict " dest ", const char *restrict " src \
152 ", size_t " n );
153 Copy at most
154 .I n
155 bytes from string
156 .I src
158 .IR dest ,
159 returning a pointer to the start of
160 .IR dest .
162 .BI "char *strpbrk(const char *" s ", const char *" accept );
163 Return a pointer to the first occurrence in the string
164 .I s
165 of one of the bytes in the string
166 .IR accept .
168 .BI "char *strrchr(const char *" s ", int " c );
169 Return a pointer to the last occurrence of the character
170 .I c
171 in the string
172 .IR s .
174 .BI "char *strsep(char **restrict " stringp ", const char *restrict " delim );
175 Extract the initial token in
176 .I stringp
177 that is delimited by one of the bytes in
178 .IR delim .
180 .BI "size_t strspn(const char *" s ", const char *" accept );
181 Calculate the length of the starting segment in the string
182 .I s
183 that consists entirely of bytes in
184 .IR accept .
186 .BI "char *strstr(const char *" haystack ", const char *" needle );
187 Find the first occurrence of the substring
188 .I needle
189 in the string
190 .IR haystack ,
191 returning a pointer to the found substring.
193 .BI "char *strtok(char *restrict " s ", const char *restrict " delim );
194 Extract tokens from the string
195 .I s
196 that are delimited by one of the bytes in
197 .IR delim .
199 .BI "size_t strxfrm(char *restrict " dst ", const char *restrict " src \
200 ", size_t " n );
201 Transforms
202 .I src
203 to the current locale and copies the first
204 .I n
205 bytes to
206 .IR dst .
207 .SH DESCRIPTION
208 The string functions perform operations on null-terminated
209 strings.
210 See the individual man pages for descriptions of each function.
211 .SH SEE ALSO
212 .BR bstring (3),
213 .BR index (3),
214 .BR rindex (3),
215 .BR stpcpy (3),
216 .BR strcasecmp (3),
217 .BR strcat (3),
218 .BR strchr (3),
219 .BR strcmp (3),
220 .BR strcoll (3),
221 .BR strcpy (3),
222 .BR strcspn (3),
223 .BR strdup (3),
224 .BR strfry (3),
225 .BR strlen (3),
226 .BR strncasecmp (3),
227 .BR strncat (3),
228 .BR strncmp (3),
229 .BR strncpy (3),
230 .BR strpbrk (3),
231 .BR strrchr (3),
232 .BR strsep (3),
233 .BR strspn (3),
234 .BR strstr (3),
235 .BR strtok (3),
236 .BR strxfrm (3)