title: C++ For Loop inside a While loop
body: <p>I'm trying to write a program which takes measurements from a user and inputs them into a vector. The while loop continues until the user inputs '|' at which point it breaks out of the loops and prints the measurements. The problem I am having however is that when trying to add the measurements to the vector. I have used the debugger and found that the loops never actually enters the for loop, thus not being able to reach the "push_back statement".</p>
  
  <p>This program is part of the drills in the Bjarne Stroustup PPP c++ book. </p>
  
  <pre><code> #include "../../std_lib_facilities.h"
  
  double metreConvert (double userInput , String unit) {
  
  if (unit == "cm")
  userInput = userInput / 100;
  else if (unit == "in")
  userInput = (userInput * 2.54) / 100;
  else if (unit == "ft")
  userInput = ((userInput * 12) * 2.54) / 100;
  else if (unit == "m")
  userInput;
  
  return userInput;
  }
  
  void numbers() {
  double input; 
  String unit;
  vector &lt;double&gt; measurements;
  
      while (cin &gt;&gt; input &gt;&gt; unit &amp;&amp; input != '|'){
      if (unit == "cm")
      input = input / 100;
      else if (unit == "in")
      input = (input * 2.54) / 100;
      else if (unit == "ft")
      input = ((input * 12) * 2.54) / 100;
      else if (unit == "m")
      input;
          for (int i=0; measurements.size(); i++){
              if (i == 0 || input != measurements[i]){
              cout &lt;&lt; "\nPopping onto vector";
              measurements.push_back(input);
              }
              else {
              cout &lt;&lt; "\nMeasurment cannot be placed on vector";
  
          }
          }
      }
      cout &lt;&lt; "input ended";
      }
  
  void main() {
  cout &lt;&lt; "Please enter a number followed by a unit(metres,cm,inches,ft), type '|' when finished inputing:";
  numbers();
   }
  </code></pre>