title: C++ for loop input
body: <p>I have made a project using structure and pointers to display a person identity. Most of it works fine but when it come to for loop, it just messes up the entire program. The main idea was to work in this way</p>
  
  <pre><code>for (int i = 0; i &lt; 3; i++{
      cout &lt;&lt; "Whatever" &lt;&lt; endl;
      getline(cin, var_whatever[i]);
  } 
  </code></pre>
  
  <p>So it would run the loop 3 times and ask the user to input it 3 times but when this runs, it skips over the first input and goes to the second one. Here's my code and would be grateful if someone gives me a solution to this</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;Windows.h&gt;
  using namespace std;
  
  //declare structure to store info about Billy
  struct Son{
      string name;
      int age;
      string crush;
      string hobbies[3];
  }Person;
  
  int main(){
      int i;
      Son* info = new Son;
      info = &amp;Person;
      //user interface
      //Person's name
      cout &lt;&lt; "Person's name: ";
      getline(cin, info -&gt;name); //inputs person's name
      //Person's age
      cout &lt;&lt; "Person's age: ";
      cin &gt;&gt; info -&gt;age; //inputs person's age
      //for loop to get hobbies
      for(i = 0; i &lt;= 3; i++){ //main problem which is giving me headache
          cout &lt;&lt; "Write your hobby[" &lt;&lt; i &lt;&lt;"]: ";
          getline(cin,info -&gt;hobbies[i]); //inputs the person hobby three times
      }
      //Person's crush
      cout &lt;&lt; "Write your crush name: ";
      getline(cin, info -&gt;crush); //inputs the person's crush *opitional*
  
      //output statement
      cout &lt;&lt; "Name: " &lt;&lt; info -&gt;name &lt;&lt; endl; //display name
      cout &lt;&lt; "Age: " &lt;&lt; info -&gt;age &lt;&lt; endl; //display age
      for(int j = 0; j &lt; 3; j++){ //display hobbies
      cout &lt;&lt; "Hobbies[" &lt;&lt; j &lt;&lt; "]: " &lt;&lt; info -&gt;hobbies[j] &lt;&lt; endl;
      }
      cout &lt;&lt; "Crush: " &lt;&lt; info -&gt;crush &lt;&lt; endl; //display crush
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>and the output is</p>
  
  <pre><code>Person's name: Billy
  Person's age: 25
  Write your hobby[0]: Write your hobby[1]:soccer
  write your hobby[2]:basketball
  write your hobby[3]:Kungfu
  Write your crush name: Jake
  Name:Billy
  Age:25
  Hobbies[0]:
  Hobbies[1]:soccer
  Hobbies[2]:basketball
  Crush: Jake
  </code></pre>
  
  <p>This code output is hell and anyway
  Thank You for your time</p>