Hi, I'm having some problems understanding what I need to do for the function find_if(). I was reading the article on this website and it looks like this is the way I should be calling the unary function, but the compiler is telling me this isn't so. I'm supposed to have the program run through and clean the words of any punctuation at the beginning of the string and then run through the string and look for punctuation. If there is punctuation in the middle, I'm supposed to "clean" everything after that. So I've run this
void clean_entry( const string& s1, string& s2 )
size_t start=0, finish=0;
start = find_if (s1.begin(), s1.end(), isalnum); //finds position to start
finish = find_if(s1.begin(), s1.end(),!(isalnum)); //finds position to end
s2 = s1.substr (start, finish); // purges the string of everything after
for_each (s2.begin(), s2.end(), lower); //converts all letters to lowercase
and am getting the following errors:
prog4.cc: In function ‘void clean_entry(const string&, std::string&)’:
prog4.cc:59:47: error: no matching function for call to ‘find_if(std::basic_string<char>::const_iterator, std::basic_string<char>::const_iterator, <unresolved overloaded function type>)’
prog4.cc:59:47: note: candidate is:
/usr/include/c++/4.6/bits/stl_algo.h:4418:5: note: template<class _IIter, class _Predicate> _IIter std::find_if(_IIter, _IIter, _Predicate)
prog4.cc:60:48: error: cannot resolve overloaded function ‘isalnum’ based on conversion to type ‘bool’
prog4.cc:60:48: error: in argument to unary !
any help guys?