hey guys, I'm having some difficulty with finding out whether a user inputted string is a palindrome. It doesn't have to identify pure palindromes either, just the basics. Everything was going great, and just as it was looking like I'd get to bed before 3 am, I got hit with a segmentation fault. I messed around with it alot, and bypassed that error, but now it cuts a letter off the user inputted string.
for example:
say I input ffaff
It will read faff, and tell me no palindrome exists.
I have a feeling it has something to do with the arrays, as I'm not very knowledgeable on that front because we've yet to cover them in class. Thanks in advance!!!
#include <iostream>
using namespace std;
bool Palindrome(string pal, int index, int length)
{
int total;
pal[index] = 30;
if ((length == 0 || length == 1))
{
cout << pal << ", is infact a palindrome." << endl;
return true;
}
if (pal[index] == pal[length - 1 - index])
return Palindrome(pal, index++, length);
else
{
cout << pal << ", is infact not a palindrome." << endl;
return false;
}
}
int main () {
string word;
cout << "Enter your prospective palindrome." << endl;
cin >> word;
Palindrome(word, 0, word.length());
return 0;
}