find returns an index, not a string. For example, if the string is "atest" and you search for "test", find would return 1. Then you could do this:
int index = s.find ( "test" );
if ( index != string::npos )
cout<< s.substr ( index ) <<endl;
And "test" would be printed. Note that while I used int for the index, the proper type is string::size_type:
string::size_type index = s.find ( "test" );
if ( index != string::npos )
cout<< s.substr ( index ) <<endl;
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401