]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
4 | .\" |
5 | .\" References consulted: | |
6 | .\" Linux libc source code | |
7 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
8 | .\" 386BSD man pages | |
9 | .\" Modified Sun Jul 25 10:54:31 1993, Rik Faith (faith@cs.unc.edu) | |
45186a5d | 10 | .TH STRING 3 2021-03-22 "Linux man-pages (unreleased)" |
fea681da | 11 | .SH NAME |
513785e2 | 12 | stpcpy, strcasecmp, strcat, strchr, strcmp, strcoll, strcpy, strcspn, |
fea681da MK |
13 | strdup, strfry, strlen, strncat, strncmp, strncpy, strncasecmp, strpbrk, |
14 | strrchr, strsep, strspn, strstr, strtok, strxfrm, index, rindex | |
15 | \- string operations | |
09781c32 AC |
16 | .SH LIBRARY |
17 | Standard C library | |
8fc3b2cf | 18 | .RI ( libc ", " \-lc ) |
fea681da | 19 | .SH SYNOPSIS |
fea681da | 20 | .B #include <strings.h> |
0612e12e | 21 | .TP |
fea681da | 22 | .BI "int strcasecmp(const char *" s1 ", const char *" s2 ); |
dd827c27 | 23 | Compare the strings |
0612e12e MMS |
24 | .I s1 |
25 | and | |
26 | .I s2 | |
dd827c27 | 27 | ignoring case. |
0612e12e | 28 | .TP |
fea681da | 29 | .BI "int strncasecmp(const char *" s1 ", const char *" s2 ", size_t " n ); |
dd827c27 | 30 | Compare the first |
0612e12e | 31 | .I n |
51d8bd57 | 32 | bytes of the strings |
0612e12e | 33 | .I s1 |
d3532647 MK |
34 | and |
35 | .I s2 | |
dd827c27 | 36 | ignoring case. |
0612e12e | 37 | .TP |
fea681da | 38 | .BI "char *index(const char *" s ", int " c ); |
dd827c27 | 39 | Return a pointer to the first occurrence of the character |
d3532647 | 40 | .I c |
dd827c27 | 41 | in the string |
0612e12e MMS |
42 | .IR s . |
43 | .TP | |
fea681da | 44 | .BI "char *rindex(const char *" s ", int " c ); |
dd827c27 | 45 | Return a pointer to the last occurrence of the character |
0612e12e | 46 | .I c |
dd827c27 | 47 | in the string |
0612e12e MMS |
48 | .IR s . |
49 | .TP | |
fea681da | 50 | .B #include <string.h> |
0612e12e | 51 | .TP |
9180299e | 52 | .BI "char *stpcpy(char *restrict " dest ", const char *restrict " src ); |
0612e12e MMS |
53 | Copy a string from |
54 | .I src | |
55 | to | |
dd827c27 MK |
56 | .IR dest , |
57 | returning a pointer to the end of the resulting string at | |
0612e12e MMS |
58 | .IR dest . |
59 | .TP | |
9180299e | 60 | .BI "char *strcat(char *restrict " dest ", const char *restrict " src ); |
dd827c27 | 61 | Append the string |
0612e12e | 62 | .I src |
dd827c27 MK |
63 | to the string |
64 | .IR dest , | |
65 | returning a pointer | |
0612e12e MMS |
66 | .IR dest . |
67 | .TP | |
fea681da | 68 | .BI "char *strchr(const char *" s ", int " c ); |
dd827c27 | 69 | Return a pointer to the first occurrence of the character |
0612e12e | 70 | .I c |
dd827c27 | 71 | in the string |
0612e12e MMS |
72 | .IR s . |
73 | .TP | |
fea681da | 74 | .BI "int strcmp(const char *" s1 ", const char *" s2 ); |
dd827c27 | 75 | Compare the strings |
0612e12e MMS |
76 | .I s1 |
77 | with | |
dd827c27 | 78 | .IR s2 . |
0612e12e | 79 | .TP |
fea681da | 80 | .BI "int strcoll(const char *" s1 ", const char *" s2 ); |
dd827c27 | 81 | Compare the strings |
0612e12e MMS |
82 | .I s1 |
83 | with | |
84 | .I s2 | |
85 | using the current locale. | |
86 | .TP | |
9180299e | 87 | .BI "char *strcpy(char *restrict " dest ", const char *restrict " src ); |
dd827c27 | 88 | Copy the string |
0612e12e MMS |
89 | .I src |
90 | to | |
dd827c27 MK |
91 | .IR dest , |
92 | returning a pointer to the start of | |
93 | .IR dest . | |
0612e12e | 94 | .TP |
fea681da | 95 | .BI "size_t strcspn(const char *" s ", const char *" reject ); |
dd827c27 | 96 | Calculate the length of the initial segment of the string |
0612e12e | 97 | .I s |
dd827c27 MK |
98 | which does not contain any of bytes in the string |
99 | .IR reject , | |
0612e12e | 100 | .TP |
fea681da | 101 | .BI "char *strdup(const char *" s ); |
dd827c27 | 102 | Return a duplicate of the string |
0612e12e | 103 | .I s |
dd827c27 | 104 | in memory allocated using |
d067764a | 105 | .BR malloc (3). |
0612e12e | 106 | .TP |
fea681da | 107 | .BI "char *strfry(char *" string ); |
0612e12e | 108 | Randomly swap the characters in |
dd827c27 | 109 | .IR string . |
0612e12e | 110 | .TP |
fea681da | 111 | .BI "size_t strlen(const char *" s ); |
dd827c27 | 112 | Return the length of the string |
0612e12e MMS |
113 | .IR s . |
114 | .TP | |
9180299e AC |
115 | .BI "char *strncat(char *restrict " dest ", const char *restrict " src \ |
116 | ", size_t " n ); | |
dd827c27 | 117 | Append at most |
0612e12e | 118 | .I n |
51d8bd57 | 119 | bytes from the string |
0612e12e | 120 | .I src |
dd827c27 MK |
121 | to the string |
122 | .IR dest , | |
123 | returning a pointer to | |
0612e12e MMS |
124 | .IR dest . |
125 | .TP | |
fea681da | 126 | .BI "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n ); |
0612e12e MMS |
127 | Compare at most |
128 | .I n | |
dd827c27 | 129 | bytes of the strings |
0612e12e MMS |
130 | .I s1 |
131 | and | |
c367cd59 | 132 | .IR s2 . |
0612e12e | 133 | .TP |
9180299e AC |
134 | .BI "char *strncpy(char *restrict " dest ", const char *restrict " src \ |
135 | ", size_t " n ); | |
0612e12e MMS |
136 | Copy at most |
137 | .I n | |
dd827c27 | 138 | bytes from string |
0612e12e MMS |
139 | .I src |
140 | to | |
dd827c27 MK |
141 | .IR dest , |
142 | returning a pointer to the start of | |
143 | .IR dest . | |
0612e12e | 144 | .TP |
fea681da | 145 | .BI "char *strpbrk(const char *" s ", const char *" accept ); |
dd827c27 | 146 | Return a pointer to the first occurrence in the string |
0612e12e | 147 | .I s |
dd827c27 | 148 | of one of the bytes in the string |
0612e12e MMS |
149 | .IR accept . |
150 | .TP | |
fea681da | 151 | .BI "char *strrchr(const char *" s ", int " c ); |
dd827c27 MK |
152 | Return a pointer to the last occurrence of the character |
153 | .I c | |
154 | in the string | |
155 | .IR s . | |
0612e12e | 156 | .TP |
b0ef498b | 157 | .BI "char *strsep(char **restrict " stringp ", const char *restrict " delim ); |
dd827c27 | 158 | Extract the initial token in |
0612e12e | 159 | .I stringp |
dd827c27 | 160 | that is delimited by one of the bytes in |
0612e12e MMS |
161 | .IR delim . |
162 | .TP | |
fea681da | 163 | .BI "size_t strspn(const char *" s ", const char *" accept ); |
dd827c27 | 164 | Calculate the length of the starting segment in the string |
0612e12e | 165 | .I s |
dd827c27 | 166 | that consists entirely of bytes in |
0612e12e MMS |
167 | .IR accept . |
168 | .TP | |
fea681da | 169 | .BI "char *strstr(const char *" haystack ", const char *" needle ); |
dd827c27 | 170 | Find the first occurrence of the substring |
0612e12e | 171 | .I needle |
dd827c27 MK |
172 | in the string |
173 | .IR haystack , | |
174 | returning a pointer to the found substring. | |
0612e12e | 175 | .TP |
9180299e | 176 | .BI "char *strtok(char *restrict " s ", const char *restrict " delim ); |
dd827c27 | 177 | Extract tokens from the string |
0612e12e | 178 | .I s |
dd827c27 | 179 | that are delimited by one of the bytes in |
0612e12e MMS |
180 | .IR delim . |
181 | .TP | |
9180299e AC |
182 | .BI "size_t strxfrm(char *restrict " dst ", const char *restrict " src \ |
183 | ", size_t " n ); | |
0612e12e MMS |
184 | Transforms |
185 | .I src | |
186 | to the current locale and copies the first | |
187 | .I n | |
51d8bd57 | 188 | bytes to |
9180299e | 189 | .IR dst . |
fea681da | 190 | .SH DESCRIPTION |
69263796 | 191 | The string functions perform operations on null-terminated |
c13182ef MK |
192 | strings. |
193 | See the individual man pages for descriptions of each function. | |
47297adb | 194 | .SH SEE ALSO |
5b72a113 | 195 | .BR bstring (3), |
fea681da MK |
196 | .BR index (3), |
197 | .BR rindex (3), | |
513785e2 | 198 | .BR stpcpy (3), |
3e5c319e | 199 | .BR strcasecmp (3), |
fea681da MK |
200 | .BR strcat (3), |
201 | .BR strchr (3), | |
202 | .BR strcmp (3), | |
203 | .BR strcoll (3), | |
204 | .BR strcpy (3), | |
205 | .BR strcspn (3), | |
206 | .BR strdup (3), | |
207 | .BR strfry (3), | |
208 | .BR strlen (3), | |
209 | .BR strncasecmp (3), | |
210 | .BR strncat (3), | |
211 | .BR strncmp (3), | |
212 | .BR strncpy (3), | |
213 | .BR strpbrk (3), | |
214 | .BR strrchr (3), | |
215 | .BR strsep (3), | |
216 | .BR strspn (3), | |
217 | .BR strstr (3), | |
218 | .BR strtok (3), | |
219 | .BR strxfrm (3) |