I had that but the problem was how to solve it.
I rewrote the whole thing.Thanks for taking a look.
Code:
#include <vector>
#include <iostream>
#include <string>
bool is_palindrome ( const std::string & s )
{
return equal ( s.begin(),s.end(),s.rbegin() );
}
std::istream & read ( std::istream & s , std::vector < std::string > &v )
{
if ( s ){
std::string temp_store;
while ( s >> temp_store )
if ( is_palindrome ( temp_store))
v.push_back(temp_store);
}
return s;
}
/*std::vector< std::string > check_for_palindrome ( std::istream & s )
{
std::vector < std::string > palindrome_words;
std::string word_read;
while( read ( s , word_read )){
if ( is_palindrome ( word_read ) )
palindrome_words.push_back(word_read);
}
return palindrome_words;
} */
int main ( int argc ,char * argv[] )
{
std::vector < std::string > words_reported_palindrome;
//words_reported_palindrome =check_for_palindrome ( std:: cin );
read ( std::cin , words_reported_palindrome );
typedef std::vector < std::string > ::const_iterator iter;
for ( iter my_iter = words_reported_palindrome.begin(); my_iter != words_reported_palindrome.end(); ++my_iter)
{
std::cout << *my_iter << std::endl;
}
return 0;
}