OK, what I have got so far works well enough, but it will not ignore capitalization. What do I do?
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
cout << "Please Enter The Suspected Palindrome:";
string s;
cin >> s;
if( equal(s.begin(), s.begin() + s.size()/2, s.rbegin()) )
cout << "This is a palindrome.";
else
cout << "This is not a palindrome.";
cout << "\n\n";
system ("pause");
return 0;
}
Try converting every character to the same case (upper/lower) and then running your test.
greengirl1968
Add this bit of code that I found and it should solve your problem.
1 2 3 4 5 6 7
|
#include <locale> // heder file to use the loc variable
locale loc;
for (int lp = 0; lp < s.length(); lp++)
{
s[lp] = tolower(s[lp], loc);
}
|
Not that I know many palindromes to test this with, but it did work.
Hope that helps
Andy
PS
Forgot to mention this should go after the cin and before the if statement.
Last edited on
Thank you all very much that helped greatly.