strstr

Gamma: Version 4.0
Prev |  | Next

# `strstr`

`strstr` -- finds the location of a given substring.

## Syntax

    strstr (stringA, stringB)

## Arguments

`stringA`

  A string.

`stringB`

  A string.

## Returns

The position of `stringB` within `stringA`, or -1 if `stringA` does not contain `stringB`.

## Description

This function finds the first complete occurrence of `stringB` within `stringA` and returns the position of the starting character of the match within `stringA`. The first character in `stringA` is numbered zero. If no match is found, -1 is returned.

## Example

        Gamma> strstr("Acme widgets","get");
        8
        Gamma> strstr("Acme widgets","wide");
        -1
        Gamma>

See the Common: The Text Message Display section of the Controller Functions chapter in the Cogent Tools Demo and Tutorials book for an example of this function used in context.

## See Also

`strchr`, `strrchr`

Prev | Home | Next
`strrev` | Up | `substr`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.