COHERENT manpages

This page displays the COHERENT manpage for strstr() [Find one string within another].

List of available manpages
Index


strstr() -- String Function (libc)

Find one string within another
#include <string.h>
char *strstr(string1, string2)
char *string1, *string2;

The  string  function  strstr()  looks  for  string2  within  string1.  The
terminating NUL is not considered part of string2.

strstr() returns a pointer to  where string2 begins within string1, or NULL
if string2 does not occur within string1.

For example,

    char *string1 = "Hello, world";
    char *string2 = "world";
    strstr(string1, string2);

returns string1  plus seven, which points to the  beginning of world within
Hello, world.  On the other hand,

    char *string1 = "Hello, world";
    char *string2 = "worlds";
    strstr(string1, string2);

returns NULL because worlds does not occur within Hello, world.

See Also

libc,
string.h
ANSI Standard, §7.11.5.7
POSIX Standard, §8.1

Notes

Neither string1 nor string2 can be more than 2,147,483,647 characters long.