]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
c13182ef | 11 | .\" |
fea681da MK |
12 | .\" Since the Linux kernel and libraries are constantly changing, this |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" References consulted: | |
24 | .\" Linux libc source code | |
25 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
26 | .\" 386BSD man pages | |
27 | .\" Modified Sat Jul 24 17:56:43 1993 by Rik Faith (faith@cs.unc.edu) | |
28 | .\" Added history, aeb, 980113. | |
7257eeb8 | 29 | .\" 2005-05-05 mtk: added strcasestr() |
fea681da | 30 | .\" |
7257eeb8 | 31 | .TH STRSTR 3 2005-04-05 "GNU" "Linux Programmer's Manual" |
fea681da MK |
32 | .SH NAME |
33 | strstr \- locate a substring | |
34 | .SH SYNOPSIS | |
35 | .nf | |
36 | .B #include <string.h> | |
37 | .sp | |
38 | .BI "char *strstr(const char *" haystack ", const char *" needle ); | |
7257eeb8 MK |
39 | .sp |
40 | .B #define _GNU_SOURCE | |
41 | .sp | |
42 | .B #include <string.h> | |
43 | .sp | |
44 | .BI "char *strcasestr(const char *" haystack ", const char *" needle ); | |
fea681da MK |
45 | .fi |
46 | .SH DESCRIPTION | |
63aa9df0 | 47 | The \fBstrstr\fP() function finds the first occurrence of the substring |
1c44bd5b MK |
48 | \fIneedle\fP in the string \fIhaystack\fP. |
49 | The terminating \`\\0' characters are not compared. | |
7257eeb8 | 50 | |
63aa9df0 | 51 | The \fBstrcasestr\fP() function is like \fBstrstr\fP(), |
7257eeb8 | 52 | but ignores the case of both arguments. |
fea681da | 53 | .SH "RETURN VALUE" |
7257eeb8 | 54 | These functions return a pointer to the beginning of the |
fea681da MK |
55 | substring, or NULL if the substring is not found. |
56 | .SH BUGS | |
57 | Early versions of Linux libc (like 4.5.26) would not allow | |
63aa9df0 | 58 | an empty \fIneedle\fP argument for \fBstrstr\fP(). |
7257eeb8 | 59 | Later versions (like 4.6.27) work correctly, |
fea681da MK |
60 | and return \fIhaystack\fP when \fIneedle\fP is empty. |
61 | .SH "CONFORMING TO" | |
68e1685c | 62 | The \fBstrstr\fP() function conforms to C89 and C99. |
63aa9df0 | 63 | The \fBstrcasestr\fP() function is a non-standard extension. |
fea681da MK |
64 | .SH "SEE ALSO" |
65 | .BR index (3), | |
66 | .BR memchr (3), | |
67 | .BR rindex (3), | |
68 | .BR strchr (3), | |
7257eeb8 | 69 | .BR strcasecmp (3), |
fea681da MK |
70 | .BR strpbrk (3), |
71 | .BR strsep (3), | |
72 | .BR strspn (3), | |
1709027c | 73 | .BR strtok (3), |
0a90178c MK |
74 | .BR wcsstr (3), |
75 | .BR feature_test_macros (7) |