find
Syntax:
#include <string> size_type find( const string& str, size_type index ); size_type find( const char* str, size_type index ); size_type find( const char* str, size_type index, size_type length ); size_type find( char ch, size_type index ); The function find() 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; } |