.TH strstr() "" "" "String Function (libc)"
.II "find one string within another"
.II "string, find one within another"
.PC "Find one string within another"
.B "#include <string.h>"
\fBchar *strstr(\fIstring1\^\fB, \fIstring2\^\fB)\fR
\fBchar *\fIstring1\^\fB, *\fIstring2\^\fB;\fR
.PP
The string function
.B strstr()
looks for
.I string2
within
.IR string1 .
The terminating NUL is not considered part of
.IR string2 .
.PP
.B strstr()
returns a pointer to where
.I string2
begins within
.IR string1 ,
or NULL if
.I string2
does not occur within
.IR string1 .
.PP
For example,
.DM
	char *string1 = "Hello, world";
	char *string2 = "world";
	strstr(string1, string2);
.DE
.PP
returns \fBstring1\fR plus seven, which points to the beginning of
\fBworld\fR within \fBHello, world\fR.
On the other hand,
.DM
	char *string1 = "Hello, world";
	char *string2 = "worlds";
	strstr(string1, string2);
.DE
.PP
returns NULL because \fBworlds\fR does not occur within \fBHello, world\fR.
.SH "See Also"
.Xr "libc," libc
.Xr "string.h" string.h
.br
\*(AS, \(sc7.11.5.7
.br
\*(PX Standard, \(sc8.1
.SH Notes
Neither
.I string1
nor
.I string2
can be more than 2,147,483,647 characters long.
