I am working on a problem where I am trying to find a palindrome using a stack and queue. Below is the code that I am using to try and determine if a string is a palindrome or not. Right now I am having problems. It seems as though this program is only checking and comparing the first and last character in the string, and as long as they are the same, it is saying "this is a palindrome." For example, I can input "i alskdflkajsfkjasf i" and it will tell me that it is a palindrome. Can anyone tell me what might be the problem? Thanks
#include <iostream>
#include <string>
#include "stack.h"
#include "queue.h"
using namespace std;
int main()
{
Stack S;
Queue Q;
string s ;
int i = 0;
char string[MAX];
bool RESULT = false;
cout << "Enter a line to check for palindrome: " << endl;
cin.getline (string,100);
while(string[i]!= 0)
{
S.push(string[i]);
Q.addQueue(string[i]);
i++;
}
while(i > 0)
{
if(S.pop() == Q.frontQueue())
{
RESULT = true;
}
else
{
RESULT = false;
break;
}
i--;
}
if(RESULT == true)
{
cout<<string<<" \nThis is a palindrome\n";
}
else
{
cout<<string<<" \nThis is not a palindrome\n";
}
return 0;
}