Can anyone tell me what I am doing wrong in this code? The output window allows me to input the string, but does not output whether or not it is a palindrom. There are no build errors
Thanks in advance!
Lauren
#include <iostream>
#include <deque>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string input;
deque<string> stackOne;
deque<string> stackTwo;
cout << "Enter text to see if it is a palindrome. Please do not include spaces or punctuation.\n";
getline(cin, input);// this allows you to get user input
stackOne.push_front(input);
while(!stackOne.empty()) // this part reads stackOne into stackTwo.
{
input = stackOne.front();//retrieve the user entered input
stackTwo.push_front(input); // put input into stack two at the front
}
if(stackOne == stackTwo)
{
cout << "It is a palindrome." << endl;
}
else
cout << "It is not a palindrome." << endl;
return 0;
}
Also, any suggestions on how I can change this code so that the string is read into the two stacks one character at a time, so that I can compare them that way. And just to let you know, yes this is a homework assignment. I just need help getting a better sense of direction. THanks again
Oh, and one more thing, I can't use an array