|
strstrfunction
<cstring>
const char * strstr ( const char * str1, const char * str2 ); char * strstr ( char * str1, const char * str2 ); Locate substring Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1.The matching process does not include the terminating null-characters. Parameters
Return ValueA 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.PortabilityIn C, this function is declared as:char * strstr ( const char *, const char * ); instead of the two overloaded versions provided in C++. Example
This example searches for the "simple" substring in str and replaces that word for "sample". Output:
See also
|