title: Reading a postfix expression as a string from a txt file
body: <p>This is part of my C++ assignment.  I need to write three functions in the project.  When i start my work, I found a huge problem, the first function.</p>
  
  <p>First of all, the program is like this:</p>
  
  <ol>
  <li>Open the postfix expression file</li>
  <li>Use getline to read line by line (each line is an expression)</li>
  <li>Evaluate the expression step by step</li>
  </ol>
  
  <p>I know that I need to call the function to know the next operand and then to calculate the intermediate result.  The <code>nextOperand</code> function returns the value of the next operand (datatype: double) that starts at index I of the input string.</p>
  
  <p>This is what I have now:</p>
  
  <pre><code>double nextOperand(const string&amp; expr, int&amp; i)
  {
      // You can make use of the function stod(string) string-to-double,
      // and the function substring() to extract an operand from the expression:
      // Example:
      //   string myExpression = "1.5 2.3 +";
      //   int pos = 0;
      //   int len = 3;
      //   string opderand = myExpression.substr(pos, len); 
      //   double value = stod(opderand);
      stack&lt;char&gt; temp;
      string temp1;
  
      while(expr[i] != ' ' &amp;&amp; !isOperator(expr[i]))
      {
          temp.push(expr[i]);
          i++;
      }
  
      while(!temp.empty())
      {
          temp1 = temp.top() + temp1;
          temp.pop();
      }
      if(temp1 != "\0")
      {
          double value = stod(temp1);
          return value;
      }
      else 
          return 0;
  }
  </code></pre>
  
  <p>The function to evaluate postfix and prefix expressions are not yet programmed.  I wish to finish this <code>nextOperand</code> function first to continue.</p>