'\" t .\" Copyright 1993, David Metcalfe .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .TH strstr 3 2026-08-10 "Linux man-pages 6.19" .SH NAME strstr \- string search substring .SH LIBRARY Standard C library .RI ( libc ,\~ \-lc ) .SH SYNOPSIS .nf .B #include .P .BI "char *strstr(const char *" haystack ", const char *" needle ); .fi .SH DESCRIPTION .BR strstr () finds the first occurrence of the substring .I needle in the string .IR haystack . .P The terminating null bytes (\[aq]\[rs]0\[aq]) are not compared. .P It is equivalent to .P .in +4n .EX memmem(haystack, strlen(haystack), needle, strlen(needle)) .EE .in .SH RETURN VALUE .BR strstr (3) returns a pointer to the beginning of the located substring, or NULL if the substring is not found. .P If .I needle is the empty string, the return value is always .I haystack itself. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ .na .nh .BR strstr () T} Thread safety MT-Safe .TE .SH STANDARDS C11, POSIX.1-2008. .SH HISTORY POSIX.1-2001, C89. .SH SEE ALSO .BR strcasestr (3), .BR strchr (3), .BR string (3), .BR strpbrk (3), .BR strsep (3), .BR strspn (3), .BR wcsstr (3)