Name
strstr, strcasestr - locate a substringLibrary
Standard C library ( libc ", " -lc )Synopsis
#include <string.h> char *strstr(const char *" haystack ", const char * needle );
"#define(7)_GNU_SOURCE" " /* See feature_test_macros */" #include <string.h> char *strcasestr(const char *" haystack ", const char * needle );
Description
The strstr() function finds the first occurrence of the substring needle in the stringhaystack
. The terminating null bytes ('\e0') are not compared. The strcasestr() function is like strstr() but ignores the case of both arguments.
Return Value
These functions return 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 |
T} | Thread safety | MT-Safe |
T} | Thread safety | MT-Safe locale |
Standards
strstr() C11, POSIX.1-2008.
strcasestr() GNU.
History
strstr() POSIX.1-2001, C89.
strcasestr() GNU.