find

Syntax:

    #include <string>
    size_type find( const string& str, size_type index = 0 ) const;
    size_type find( const char* str, size_type index = 0 ) const;
    size_type find( const char* str, size_type index, size_type length ) const;
    size_type find( char ch, size_type index = 0 ) const;

The function find() returns either:

For example:

     string str1( "Alpha Beta Gamma Delta" );
     string::size_type loc = str1.find( "Omega", 0 );
     if( loc != string::npos ) {
       cout << "Found Omega at " << loc << endl;
     } else {
       cout << "Didn't find Omega" << endl;
     }

Related Topics: find_first_not_of, find_first_of, find_last_not_of, find_last_of, rfind