xref: /freebsd/lib/libc/string/string.3 (revision 4b9d6057)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd September 2, 2023
31.Dt STRING 3
32.Os
33.Sh NAME
34.Nm stpcpy ,
35.Nm strcat ,
36.Nm strncat ,
37.Nm strchr ,
38.Nm strrchr ,
39.Nm strcmp ,
40.Nm strncmp ,
41.Nm strcasecmp ,
42.Nm strncasecmp ,
43.Nm strcpy ,
44.Nm strncpy ,
45.Nm strerror ,
46.Nm strlen ,
47.Nm strpbrk ,
48.Nm strsep ,
49.Nm strspn ,
50.Nm strcspn ,
51.Nm strstr ,
52.Nm strtok ,
53.Nm index ,
54.Nm rindex
55.Nd string specific functions
56.Sh LIBRARY
57.Lb libc
58.Sh SYNOPSIS
59.In string.h
60.Ft char *
61.Fn stpcpy "char *dst" "const char *src"
62.Ft char *
63.Fn strcat "char *s" "const char * append"
64.Ft char *
65.Fn strncat "char *s" "const char *append" "size_t count"
66.Ft char *
67.Fn strchr "const char *s" "int c"
68.Ft char *
69.Fn strrchr "const char *s" "int c"
70.Ft int
71.Fn strcmp "const char *s1" "const char *s2"
72.Ft int
73.Fn strncmp "const char *s1" "const char *s2" "size_t count"
74.Ft int
75.Fn strcasecmp "const char *s1" "const char *s2"
76.Ft int
77.Fn strncasecmp "const char *s1" "const char *s2" "size_t count"
78.Ft char *
79.Fn strcpy "char *dst" "const char *src"
80.Ft char *
81.Fn strncpy "char *dst" "const char *src" "size_t count"
82.Ft char *
83.Fn strerror "int errno"
84.Ft size_t
85.Fn strlen "const char *s"
86.Ft char *
87.Fn strpbrk "const char *s" "const char *charset"
88.Ft char *
89.Fn strsep "char **stringp" "const char *delim"
90.Ft size_t
91.Fn strspn "const char *s" "const char *charset"
92.Ft size_t
93.Fn strcspn "const char *s" "const char *charset"
94.Ft char *
95.Fn strstr "const char *big" "const char *little"
96.Ft char *
97.Fn strtok "char *s" "const char *delim"
98.Ft char *
99.Fn index "const char *s" "int c"
100.Ft char *
101.Fn rindex "const char *s" "int c"
102.Sh DESCRIPTION
103The string
104functions manipulate strings terminated by a
105null byte.
106.Pp
107See the specific manual pages for more information.
108For manipulating variable length generic objects as byte
109strings (without the null byte check), see
110.Xr bstring 3 .
111.Pp
112Except as noted in their specific manual pages,
113the string functions do not test the destination
114for size limitations.
115.Sh SEE ALSO
116.Xr bstring 3 ,
117.Xr index 3 ,
118.Xr rindex 3 ,
119.Xr stpcpy 3 ,
120.Xr strcasecmp 3 ,
121.Xr strcat 3 ,
122.Xr strchr 3 ,
123.Xr strcmp 3 ,
124.Xr strcpy 3 ,
125.Xr strcspn 3 ,
126.Xr strerror 3 ,
127.Xr strlen 3 ,
128.Xr strpbrk 3 ,
129.Xr strrchr 3 ,
130.Xr strsep 3 ,
131.Xr strspn 3 ,
132.Xr strstr 3 ,
133.Xr strtok 3 ,
134.Xr simd 7
135.Sh STANDARDS
136The
137.Fn strcat ,
138.Fn strncat ,
139.Fn strchr ,
140.Fn strrchr ,
141.Fn strcmp ,
142.Fn strncmp ,
143.Fn strcpy ,
144.Fn strncpy ,
145.Fn strerror ,
146.Fn strlen ,
147.Fn strpbrk ,
148.Fn strspn ,
149.Fn strcspn ,
150.Fn strstr ,
151and
152.Fn strtok
153functions
154conform to
155.St -isoC .
156