title: Not able to generate correct output in recursive function?
body: <p>I'm trying to write a function that detects the number the negative integers in a stack recursively. Currently the snippet below is what I have, however it is not giving the correct answer so far. I tested with a stack of 11 elements with 7 negatives and got the output given below. There is definitely something wrong with the loop structure but I have not been able to pinpoint and fix it yet. Any help will be appreciated! </p>
  
  <pre><code>12356657235681623569772357137235729723574562357617235777623579372358096
  </code></pre>
  
  <p>My function below:</p>
  
  <pre><code>size_t r_func(stack&lt;int&gt; st1)
  {   
      if(st1.size() == 0) return 0;
      int r = st1.top();
      st1.pop();
      cout &lt;&lt; (r&lt;0)+r_func(st1);
  }
  </code></pre>