tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man3 / strstr.3
blob25bbf9b27bb05322d4d21aa2f4712ef067700aa3
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\"     Linux libc source code
8 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\"     386BSD man pages
10 .\" Modified Sat Jul 24 17:56:43 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Added history, aeb, 980113.
12 .\" 2005-05-05 mtk: added strcasestr()
13 .\"
14 .TH strstr 3 (date) "Linux man-pages (unreleased)"
15 .SH NAME
16 strstr, strcasestr \- locate a substring
17 .SH LIBRARY
18 Standard C library
19 .RI ( libc ", " \-lc )
20 .SH SYNOPSIS
21 .nf
22 .B #include <string.h>
23 .PP
24 .BI "char *strstr(const char *" haystack ", const char *" needle );
25 .PP
26 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
27 .B #include <string.h>
28 .PP
29 .BI "char *strcasestr(const char *" haystack ", const char *" needle );
30 .fi
31 .SH DESCRIPTION
32 The
33 .BR strstr ()
34 function finds the first occurrence of the substring
35 .I needle
36 in the string
37 .IR haystack .
38 The terminating null bytes (\[aq]\e0\[aq]) are not compared.
39 .PP
40 The
41 .BR strcasestr ()
42 function is like
43 .BR strstr (),
44 but ignores the case of both arguments.
45 .SH RETURN VALUE
46 These functions return a pointer to the beginning of the
47 located substring, or NULL if the substring is not found.
48 .PP
50 .I needle
51 is the empty string,
52 the return value is always
53 .I haystack
54 itself.
55 .SH ATTRIBUTES
56 For an explanation of the terms used in this section, see
57 .BR attributes (7).
58 .ad l
59 .nh
60 .TS
61 allbox;
62 lbx lb lb
63 l l l.
64 Interface       Attribute       Value
66 .BR strstr ()
67 T}      Thread safety   MT-Safe
69 .BR strcasestr ()
70 T}      Thread safety   MT-Safe locale
71 .TE
72 .hy
73 .ad
74 .sp 1
75 .SH STANDARDS
76 .BR strstr ():
77 POSIX.1-2001, POSIX.1-2008, C99.
78 .PP
79 The
80 .BR strcasestr ()
81 function is a nonstandard extension.
82 .SH SEE ALSO
83 .BR memchr (3),
84 .BR memmem (3),
85 .BR strcasecmp (3),
86 .BR strchr (3),
87 .BR string (3),
88 .BR strpbrk (3),
89 .BR strsep (3),
90 .BR strspn (3),
91 .BR strtok (3),
92 .BR wcsstr (3)