OSDN Git Service

44245e1280c4103052a28b6806ac8e2b03325a2c
[linuxjm/LDP_man-pages.git] / original / man3 / string.3
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  2014-01-04 "" "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 characters 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 *" dest ", const char *" src );
70 Copy a string from
71 .I src
72 to
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 *" dest ", const char *" 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.
103 .TP
104 .BI "char *strcpy(char *" dest ", const char *" src );
105 Copy the string
106 .I src
107 to
108 .IR dest ,
109 returning a pointer to the start of
110 .IR dest .
111 .TP
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 ,
117 .TP
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).
123 .TP
124 .BI "char *strfry(char *" string );
125 Randomly swap the characters in
126 .IR string .
127 .TP
128 .BI "size_t strlen(const char *" s );
129 Return the length of the string
130 .IR s .
131 .TP
132 .BI "char *strncat(char *" dest ", const char *" src ", size_t " n );
133 Append at most
134 .I n
135 characters from the string
136 .I src
137 to the string
138 .IR dest ,
139 returning a pointer to
140 .IR dest .
141 .TP
142 .BI "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n );
143 Compare at most
144 .I n
145 bytes of the strings
146 .I s1
147 and
148 .IR s2 .
149 .TP
150 .BI "char *strncpy(char *" dest ", const char *" src ", size_t " n );
151 Copy at most
152 .I n
153 bytes from string
154 .I src
155 to
156 .IR dest ,
157 returning a pointer to the start of
158 .IR dest .
159 .TP
160 .BI "char *strpbrk(const char *" s ", const char *" accept );
161 Return a pointer to the first occurrence in the string
162 .I s
163 of one of the bytes in the string
164 .IR accept .
165 .TP
166 .BI "char *strrchr(const char *" s ", int " c );
167 Return a pointer to the last occurrence of the character
168 .I c
169 in the string
170 .IR s .
171 .TP
172 .BI "char *strsep(char **" stringp ", const char *" delim );
173 Extract the initial token in
174 .I stringp
175 that is delimited by one of the bytes in
176 .IR delim .
177 .TP
178 .BI "size_t strspn(const char *" s ", const char *" accept );
179 Calculate the length of the starting segment in the string
180 .I s
181 that consists entirely of bytes in
182 .IR accept .
183 .TP
184 .BI "char *strstr(const char *" haystack ", const char *" needle );
185 Find the first occurrence of the substring
186 .I needle
187 in the string
188 .IR haystack ,
189 returning a pointer to the found substring.
190 .TP
191 .BI "char *strtok(char *" s ", const char *" delim );
192 Extract tokens from the string
193 .I s
194 that are delimited by one of the bytes in
195 .IR delim .
196 .TP
197 .BI "size_t strxfrm(char *" dest ", const char *" src ", size_t " n );
198 Transforms
199 .I src
200 to the current locale and copies the first
201 .I n
202 characters to
203 .IR dest .
204 .SH DESCRIPTION
205 The string functions perform string operations on null-terminated
206 strings.
207 See the individual man pages for descriptions of each function.
208 .SH SEE ALSO
209 .BR index (3),
210 .BR rindex (3),
211 .BR stpcpy (3),
212 .BR strcasecmp (3),
213 .BR strcat (3),
214 .BR strchr (3),
215 .BR strcmp (3),
216 .BR strcoll (3),
217 .BR strcpy (3),
218 .BR strcspn (3),
219 .BR strdup (3),
220 .BR strfry (3),
221 .BR strlen (3),
222 .BR strncasecmp (3),
223 .BR strncat (3),
224 .BR strncmp (3),
225 .BR strncpy (3),
226 .BR strpbrk (3),
227 .BR strrchr (3),
228 .BR strsep (3),
229 .BR strspn (3),
230 .BR strstr (3),
231 .BR strtok (3),
232 .BR strxfrm (3)
233 .SH COLOPHON
234 This page is part of release 3.67 of the Linux
235 .I man-pages
236 project.
237 A description of the project,
238 information about reporting bugs,
239 and the latest version of this page,
240 can be found at
241 \%http://www.kernel.org/doc/man\-pages/.