]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strstr.3
getauxval.3: wfix
[thirdparty/man-pages.git] / man3 / strstr.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
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 Sat Jul 24 17:56:43 1993 by Rik Faith (faith@cs.unc.edu)
30.\" Added history, aeb, 980113.
7257eeb8 31.\" 2005-05-05 mtk: added strcasestr()
fea681da 32.\"
460495ca 33.TH STRSTR 3 2015-08-08 "GNU" "Linux Programmer's Manual"
fea681da 34.SH NAME
0778327e 35strstr, strcasestr \- locate a substring
fea681da
MK
36.SH SYNOPSIS
37.nf
38.B #include <string.h>
39.sp
40.BI "char *strstr(const char *" haystack ", const char *" needle );
7257eeb8 41.sp
b80f966b 42.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
7257eeb8
MK
43.sp
44.B #include <string.h>
45.sp
46.BI "char *strcasestr(const char *" haystack ", const char *" needle );
fea681da
MK
47.fi
48.SH DESCRIPTION
60a90ecd
MK
49The
50.BR strstr ()
51function finds the first occurrence of the substring
46d8df8e
MK
52.I needle
53in the string
54.IR haystack .
71d9e7ae 55The terminating null bytes (\(aq\\0\(aq) are not compared.
7257eeb8 56
60a90ecd
MK
57The
58.BR strcasestr ()
59function is like
2777b1ca 60.BR strstr (),
7257eeb8 61but ignores the case of both arguments.
47297adb 62.SH RETURN VALUE
7257eeb8 63These functions return a pointer to the beginning of the
65b1e0ed 64located substring, or NULL if the substring is not found.
d51899bb 65.SH ATTRIBUTES
84452907
PH
66For an explanation of the terms used in this section, see
67.BR attributes (7).
68.TS
69allbox;
70lb lb lb
71l l l.
72Interface Attribute Value
73T{
d51899bb 74.BR strstr ()
84452907
PH
75T} Thread safety MT-Safe
76T{
d51899bb 77.BR strcasestr ()
84452907
PH
78T} Thread safety MT-Safe locale
79.TE
47297adb 80.SH CONFORMING TO
0f52343c
MK
81.BR strstr ():
82POSIX.1-2001, POSIX.1-2008, C89, C99.
83
60a90ecd
MK
84The
85.BR strcasestr ()
c8f2dd47 86function is a nonstandard extension.
0c2d0a66
MK
87.\" .SH BUGS
88.\" Early versions of Linux libc (like 4.5.26) would not allow
89.\" an empty
90.\" .I needle
91.\" argument for
92.\" .BR strstr ().
93.\" Later versions (like 4.6.27) work correctly,
94.\" and return
95.\" .IR haystack
96.\" when
97.\" .I needle
98.\" is empty.
47297adb 99.SH SEE ALSO
fea681da
MK
100.BR index (3),
101.BR memchr (3),
3924b70d 102.BR memmem (3),
fea681da 103.BR rindex (3),
7257eeb8 104.BR strcasecmp (3),
f0c34053 105.BR strchr (3),
d095200e 106.BR string (3),
fea681da
MK
107.BR strpbrk (3),
108.BR strsep (3),
109.BR strspn (3),
1709027c 110.BR strtok (3),
0a4f8b7b 111.BR wcsstr (3)