I wrote a program but there's a problem. I need to ignore white space and punctuation, so far i can only ignore the Cases, can someone modify my program to make it ignoring space and punctuation? My friend say ti's a interviewing question and i will reawlly be appreatied if someone can help me with this
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
bool palindrome;
cout << "Enter a word: "<<endl;
cin >> word;
for (int x=0; x < word.length()-1; x++)
{
if (tolower(word[x]) != tolower(word[word.length()-(x+1)]))
{
palindrome = false;
break;
}
else
palindrome = true;
}
if (palindrome)
cout << "It is a palindrome"<<endl;
else
cout << "It is a not palindrome"<<endl;