Aug 24, 2016 at 8:43pm
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;
}
Aug 24, 2016 at 9:11pm
Try converting every character to the same case (upper/lower) and then running your test.
Aug 25, 2016 at 5:41pm
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 Aug 25, 2016 at 5:42pm
Sep 10, 2016 at 9:13pm
Thank you all very much that helped greatly.