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 Also

strchr, strrchr