title: Can someone explain why this happens?
body: <p>It's a college project, all it has to do is ask the user for info and then output it. That part is done, so the project is done (I'm not asking for help with school work).</p>
  
  <p>I decided to add a bit more to it just for fun. I'm trying to make it know when nothing was entered by the user (just hitting enter) and tell the user to do so and start over. After it starts over more than once, it outputs the last "cout" however many times the user failed to answer something (by just hitting enter). I can't figure out why. </p>
  
  <p>Output:</p>
  
  <blockquote>
    <p>Answer every question in order for this word game to work properly.</p>
    
    <p>What is your name? 12</p>
    
    <p>How old are you? 12</p>
    
    <p>Where are you from? 12</p>
    
    <p>What's the name of your college? 12</p>
    
    <p>What is your profession? 12</p>
    
    <p>What type of animal is your pet? 12</p>
    
    <p>and what is her/his name? 12</p>
    
    <p>There once was a person named 12 who lived in 12.  At the age of 12, 12 went to college at 12.  12 graduated and went to work as a 12.  Then, 12 adopted a(n) 12 named 12.  They both lived happily ever after!</p>
    
    <p>There once was a person named 12 who lived in .  At the age of 12, 12 went to college at 12.  12 graduated and went to work as a .  Then, 12 adopted a(n) 12 named 12.  They both lived happily ever after!</p>
    
    <p>There once was a person named 12 who lived in 12.  At the age of 12, 12 went to college at 12.  12 graduated and went to work as a 12.  Then, 12 adopted a(n)  named 12.  They both lived happily ever after!</p>
    
    <p>Press any key to continue . . .</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main()
  {
      string name, city, college, prof, animal, petn;
      int age;
  
      // If no value is given for a question, start over.
      struct NoValue
      {
          static void check(string a, int cls = 100)
          {
              if (a.empty())
                  {
                  cout &lt;&lt; "\n\nAnswers cannot be blank, let's try this again..." &lt;&lt; endl;
                  cin.get();      // Pause
                  for (int i = 0; i &lt;= cls; i++)  //
                      cout &lt;&lt; "\n" &lt;&lt; endl;               // Clear screen
                  main();
              }
          }
      };
  
      cout &lt;&lt; "Answer every question in order for this word game to work properly.\n\n";
  
      // Questions
      cout &lt;&lt; "What is your name? ";
      getline(cin, name);
  
      cout &lt;&lt; "How old are you? ";
      cin &gt;&gt; age;
      cin.ignore(); // To prevent the program from printing out the next 2 questions in the same line.
  
      cout &lt;&lt; "Where are you from? ";
      getline(cin, city);
  
      cout &lt;&lt; "What's the name of your college? ";
      getline(cin, college);
  
      cout &lt;&lt; "What is your profession? ";
      getline(cin, prof);
  
      cout &lt;&lt; "What type of animal is your pet? ";
      getline(cin, animal);
  
      cout &lt;&lt; "and what is her/his name? ";
      getline(cin, petn);
  
      NoValue::check(name);
      NoValue::check(city);
      NoValue::check(college);
      NoValue::check(prof);
      NoValue::check(animal);
      NoValue::check(petn);
  
      cout &lt;&lt; "\nThere once was a person named " &lt;&lt; name &lt;&lt; " who lived in " &lt;&lt; city 
      &lt;&lt; ".  At the age of " &lt;&lt; age &lt;&lt; ", " &lt;&lt; name &lt;&lt; " went to college at " &lt;&lt; college 
      &lt;&lt; ".  " &lt;&lt; name &lt;&lt; " graduated and went to work as a " &lt;&lt; prof &lt;&lt; ".  Then, " &lt;&lt; name 
      &lt;&lt; " adopted a(n) " &lt;&lt; animal &lt;&lt; " named " &lt;&lt; petn &lt;&lt; ".  They both lived happily ever after!\n\n" &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>