I've been trying to put a loop inside this code but whenever I try to there seems to be an error. Whenever a whitespace is used it produces an Infinite loop of error. I tried Do while and Nested if loops but still nothing. Can Anyone help me?
#include<iostream>
#include<string>
#include<algorithm>
usingnamespace std;
int main ()
{
string word;
cout<<"Enter the word or sentence: ";
cin>>word;
remove(word.begin(), word.end(), ' ');
if (word == string(word.rbegin(), word.rend()))
{
cout<<"It is a Palindrome"<<endl;
cout<<endl;
}
else
{
cout<<"It is not a Palindrome"<<endl;
cout<<endl;
}
}
}