title: Stack and Queue Palindrome Program
body: <p>I am writing a program to determine if a user-entered string of characters is a palindrome.  The program compiles, however when output is printed, all strings of characters are determined to be palindromes even if they are not. I read my textbook varies times, reviewed and debugged the code dozens of times, looked at other similar palindrome questions, but I am still lost.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code> #include &lt;iostream&gt;
      #include &lt;stack&gt;
      #include &lt;queue&gt;
      #include &lt;string&gt;
      using namespace std;
  
      int main (void)
      {
        stack &lt;char&gt; s;
        queue &lt;char&gt; q;
        string letter;
        int length;
  
        cout&lt;&lt;"Please enter a series of characters."&lt;&lt;endl;
        getline (cin, letter);
        length = letter.size();
  
        for (int i=0; i&lt;length; i++)
          {
            q.push(i);
            s.push(i);
          }
  
           bool isPalindrome = true;
           while (isPalindrome==true &amp;&amp; (!s.empty() &amp;&amp; !q.empty()))
           {
             if (s.top() != q.front())
              {
                isPalindrome = false;
              }
            else
             {
              q.pop();
              s.pop();
             }
           }
  
         if(isPalindrome==false &amp;&amp; (s.empty() &amp;&amp; q.empty()))
           {
            cout&lt;&lt;"True or false: "&lt;&lt;isPalindrome&lt;&lt;endl;
            cout&lt;&lt;"Is not a palindrome."&lt;&lt;endl;
           }
         else
           {
             cout&lt;&lt;"Is a palindrome."&lt;&lt;endl;
           }
  
      }
  </code></pre>
  
  <p>I would greatly appreciate if someone could explain why this is happening.  Thank you!</p>