title: Evaluate postfix using a stack in C++
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;stack&gt;
  #include &lt;limits&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main()
  {
      string input;
      cout &lt;&lt; "Enter a postfix expression: " &lt;&lt; endl;
      getline(cin, input);
  
      int operand1, operand2, result,number;
      stack&lt;char&gt;operation;
  
      stringstream temp;
  
      int i=0;
      while (i &lt; input.length())
      {
          if (isdigit(input[i]))
          {
              operation.push(input[i]);
          }
          else
          {
              operand2 = operation.top();
              temp &lt;&lt; operation.top();
              operation.pop();
  
              operand1 = operation.top();
              temp &lt;&lt; operation.top();
              operation.pop();
  
              switch(operand1,operand2)
              {
                  case '+': result=operand1 + operand2;
                  break;
  
                  case '-': result=operand1 - operand2;
                  break;
  
                  case '*': result=operand1 * operand2;
                  break;
  
                  case '/': result=operand1 / operand2;
                  break;
              }
              operation.push(result);
          }
          i++;
      }
      cout &lt;&lt; "The result is: "&lt;&lt;temp.str()&lt;&lt;endl;
      cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
  
      return 0;
  }
  </code></pre>
  
  <p>I've changed the code and managed to obtain the "pop" value, but the operation didn't work.</p>