Debian Codegraph @

upstream/mageia-cauldron/man3/strstr.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH strstr 3 2026-02-08 "Linux man-pages 6.17"
8 .SH NAME
9 strstr, strcasestr \- locate a substring
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <string.h>
16 .P
17 .BI "char *strstr(const char *" haystack ", const char *" needle );
18 .P
19 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
20 .B #include <string.h>
21 .P
22 .BI "char *strcasestr(const char *" haystack ", const char *" needle );
23 .fi
24 .SH DESCRIPTION
25 The
26 .BR strstr ()
27 function finds the first occurrence of the substring
28 .I needle
29 in the string
30 .IR haystack .
31 The terminating null bytes (\[aq]\[rs]0\[aq]) are not compared.
32 .P
33 The
34 .BR strcasestr ()
35 function is like
36 .BR strstr (),
37 but ignores the case of both arguments.
38 .SH RETURN VALUE
39 These functions return a pointer to the beginning of the
40 located substring, or NULL if the substring is not found.
41 .P
42 If
43 .I needle
44 is the empty string,
45 the return value is always
46 .I haystack
47 itself.
48 .SH ATTRIBUTES
49 For an explanation of the terms used in this section, see
50 .BR attributes (7).
51 .TS
52 allbox;
53 lbx lb lb
54 l l l.
55 Interface Attribute Value
56 T{
57 .na
58 .nh
59 .BR strstr ()
60 T} Thread safety MT-Safe
61 T{
62 .na
63 .nh
64 .BR strcasestr ()
65 T} Thread safety MT-Safe locale
66 .TE
67 .SH STANDARDS
68 .TP
69 .BR strstr ()
70 C11, POSIX.1-2008.
71 .TP
72 .BR strcasestr ()
73 GNU.
74 .SH HISTORY
75 .TP
76 .BR strstr ()
77 POSIX.1-2001, C89.
78 .TP
79 .BR strcasestr ()
80 GNU.
81 .SH SEE ALSO
82 .BR memchr (3),
83 .BR memmem (3),
84 .BR strcasecmp (3),
85 .BR strchr (3),
86 .BR string (3),
87 .BR strpbrk (3),
88 .BR strsep (3),
89 .BR strspn (3),
90 .BR strtok (3),
91 .BR wcsstr (3)