title: Input type: Reverse polish notation evaluation C++
body: <p>I'm trying to code a calculator which evaluates a entered postfix expression.</p>
  
  <p>Currently im trying to get the input with a character array, which isn't working out too well. Maybe you have suggestions for a better input construct. Or maybe you cant spot any other mistakes, because I'm getting the wrong results...</p>
  
  <p>As you can propably see i'm fairly new to C++.</p>
  
  <p>The code I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stack&gt;
  #include &lt;string.h&gt;
  
  using namespace std;
  
  
  int performOperation(int operand1, int operand2, char op)
  {
      int ans;
      switch (op) {
      case '+':
          ans = operand2 + operand1;
          break;
      case '-':
          ans = operand2 - operand1;
          break;
      case '*':
          ans = operand2 * operand1;
          break;
      case '/':
          ans = operand2 / operand1;
          break;
      }
      return ans;
  }
  
  
  bool checkOperator(char character)
  {
      if (character == '+' || character == '-' || character == '*' || character == '/')
          return true;
      else
          return false;
  }
  
  int solvePostfix(char postfix[], int size) {
      stack&lt;int&gt; s; 
      int i = 0;
      char character;
      int value;
      value = 0;
  
      while (i &lt; size) 
      {
          character = postfix[i];
          if (isdigit(character))  //ist Operand, pushe ihn auf Stack s
          {   
              s.push(character);
          }else if (checkOperator(postfix[i]))        //ist Operator, nehme die zwei Operanden vom Stack und benutze den Operator
             {                        
              int operand1 = s.top();
              s.pop();
              int operand2 = s.top();
              s.pop();
              value = performOperation(operand1, operand2, character);
              s.push(value);      //pushe den Ergebniswert auf Stack
              }
          i++;
      }
      return value;
  }
  
  int main()
  {
      char exp[100];
  
      cout &lt;&lt; "Bitte Postfix eingeben: " &lt;&lt; endl;
      cin &gt;&gt; exp;
      int size = sizeof(exp);
  
      int val = solvePostfix(exp, size);
      cout &lt;&lt; "\nErgebnis ist: " &lt;&lt; val &lt;&lt; endl;
  }
  </code></pre>