---
name: "strstr"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/strstr"
---

# strstr(3)

string search substring

## 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)](/strstr/3.md) 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)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **strstr**() | Thread safety | MT-Safe |

## STANDARDS

C11, POSIX.1-2008.

## HISTORY

POSIX.1-2001, C89.

## SEE ALSO

[**strcasestr**(3)](/strcasestr/3.md), [**strchr**(3)](/strchr/3.md), [**string**(3)](/string/3.md), [**strpbrk**(3)](/strpbrk/3.md), [**strsep**(3)](/strsep/3.md), [**strspn**(3)](/strspn/3.md), [**wcsstr**(3)](/wcsstr/3.md)
