stack - How do i get this queue to work for the palindrome? -


i resolved bool issue, output not printing whole word front , backwards. partially. posted output down below. pretty stuck on this. have tried numerous ways of trying fix it. know there c++ guru's out there might willing lend hand , tips?

#include <iostream> #include <fstream> #include <string> using namespace std;  #include "queue.h" void print(string s1, string q1) {     cout << s1 << "  ";     cout << q1 << endl; } int main() {     bool ispalin= true;     string word;     //string temp;     stack s1;     queue q1;     void print(string, string);      cout<< " enter word see if palindrome: \n";     getline(cin, word);      cout<< "the word entered is: "<< word<< endl;     ( int = 0; i<(word.size()-1); i++)     {         string temp(word, i, 1);         s1.push(temp);      }      (int = 0; i<(word.size()-1); i++)     {         string temp(word, i,1);          q1.enqueue(temp);      }     while (!s1.empty())     {         print(s1.top(), q1.front());          if( s1.top() != q1.front())         {              ispalin = false;             s1.pop();             q1.dequeue();         }         cout<< " lets check if word palindrome" << boolalpha<< ispalin<<endl;     }  output:   enter word see if palindrome:  hello word entered is: hello l  h  lets check if word palindromefalse l  e  lets check if word palindromefalse e  l  lets check if word palindromefalse h  l  lets check if word palindromefalse queue created. 

it seems forgot declare bool ispalin; somewhere before using it.


Comments