The matching process does not include the terminating null-characters.
Parameters
- str1
- C string to be scanned.
- str2
- C string containing the sequence of characters to match.
Return Value
A pointer to the first occurrence in str1 of any of the entire sequence of characters specified in str2, or a null pointer if the sequence is not present in str1.Portability
In C, this function is declared as:char * strstr ( const char *, const char * );
instead of the two overloaded versions provided in C++.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
This example searches for the "simple" substring in str and replaces that word for "sample".
Output:
This is a sample string |
See also
| strspn | Get span of character set in string (function) |
| strpbrk | Locate character in string (function) |
| strchr | Locate first occurrence of character in string (function) |
