For my class I need to make my function able to read palindrome strings (Words that are spelled the same backwards ex: racecar) while ignoring punctuation and spaces Ive made a function that can read and print basic palindromes like racecar, but I don't know how to make it read a palindrome like ex: Was it a cat I saw?
Please help!
1 2 3 4 5 6 7 8 9
bool is_palindrome( string s )
{
string rev = s;
reverse(rev);//now string rev is reversed of s
if(rev == s)
returntrue;
elsereturnfalse;
is there a way I can take out the spaces and punctuation put into a string, Like turn Was it a cat I saw? To wasitacatisaw and have my current program detect it from there?