| strstr(3) | Library Functions Manual | strstr(3) |
NAME¶
strstr - string search substring
LIBRARY¶
Standard C library (libc, -lc)
SYNOPSIS¶
#include <string.h>
char *strstr(const char *haystack, const char *needle);
DESCRIPTION¶
strstr() finds the first occurrence of the substring needle in the string haystack.
The terminating null bytes ('\0') are not compared.
It is equivalent to
memmem(haystack, strlen(haystack), needle, strlen(needle))
RETURN VALUE¶
strstr(3) returns a pointer to the beginning of the located substring, or NULL if the substring is not found.
If needle is the empty string, the return value is always haystack itself.
ATTRIBUTES¶
For an explanation of the terms used in this section, see attributes(7).
| Interface | Attribute | Value |
| strstr () | Thread safety | MT-Safe |
STANDARDS¶
C11, POSIX.1-2008.
HISTORY¶
POSIX.1-2001, C89.
SEE ALSO¶
strcasestr(3), strchr(3), string(3), strpbrk(3), strsep(3), strspn(3), wcsstr(3)
| 2026-08-10 | Linux man-pages (unreleased) |