StrPtr::Contains( const StrPtr & )

Look for a substring and, if found, return it.

Virtual?

No

 

Class

StrPtr

 

Arguments

const StrPtr &s

the substring to look for

Returns

char *

the start of the substring if found, otherwise NULL

Notes

StrPtr::Contains() returns a pointer to the StrPtr’s buffer, rather than allocating a new buffer for the substring. If it cannot find the substring, Contains() returns NULL.

Example

#include <stdhdrs.h>
#include <strbuf.h>

int main( int argc, char **argv )
{
    StrBuf str1, str2;

    str1.Set( "the quick brown fox jumps over the lazy dog" );
    str2.Set( "brown fox" );

    printf( "%s\n", str1.Contains( str2 ) );

    return 0;
}

Executing the preceding code produces the following output:

brown fox jumps over the lazy dog