#include <iostream>
#include <string>
using namespace std;
int main( )
{
string typing( "The quick, brown fox jumps over the lazy dog" );
cout << "String: " << typing << endl;
// find last occurrence of a substring - no C-string equivalent
string::size_type index = typing.rfind( "fox" );
if( index != string::npos )
cout << "\n\"fox\" last occurs at index " << index;
else
cout << "\n\"fox\" is not in the string";
}
|