[Previous]
[Contents]
[Next]

strstr(), _fstrstr()

find one string inside another

Synopsis:

#include <string.h>

char *strstr( const char *str,
              const char *substr );
char __far *_fstrstr( const char __far *str,
                      const char __far *substr );

Description:

The strstr() function locates the first occurrence in the string pointed to by str of the sequence of characters (excluding the terminating null character) in the string pointed to by substr.

The _fstrstr() function is a data-model-independent form of the strstr() function. It accepts far pointer arguments, and returns a far pointer. It is most useful in mixed memory model applications.

Returns:

A pointer to the located string, or NULL if the string isn't found.

Examples:

#include <stdio.h>
#include <string.h>

void main()
  {
    printf( "%s\n", strstr("This is an example", "is") );
  }

produces the output:

is is an example

Classification:

strstr() is ANSI; _fstrstr() is WATCOM.
Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strcspn()


[Previous]
[Contents]
[Next]