strstr() — Locate Substring

Format

#include <string.h>

char *strstr(const char *string1, const char *string2);

General Description

The strstr() function finds the first occurrence of the string pointed to by string2 (excluding the NULL character) in the string pointed to by string1.

Returned Value

If successful, strstr() returns a pointer to the beginning of the first occurrence of string2 in string1.

If string2 does not appear in string1, strstr() returns NULL.

If string2 points to a string with zero length, strstr() returns string1.

Related Information