title: What are the rules of the std::cin object in C++?
body: <p>I am writing a small program for my personal use to practice learning C++ and for its functionality, an MLA citation generator (I'm writing a large paper with tens of citations).</p>
  <p>For lack of a better way to do it (I don't understand classes or using other .cpp files inside your main, so don't bother telling me, I'll work on that when I have more time), I am writing a function for each type of citation. I might break this down into a function for each reused code if I get more time.</p>
  <p>My question is: how does the std::cin object work? I am currently reading in with std::cin &gt;&gt; for the strings I expect to be single words, and getline(std::cin, string) for the strings with spaces. I am not getting the right output, though. I just want to know how std::cin works and why I keep unexpectedly skipping over some some inputs (for instance, it skips over webPage instead of giving me a chance to input into it).</p>
  <pre><code>void webCit() {
      std::cout &lt;&lt; &quot;Leave any unknowns blank.\n&quot;;
  
      std::cout &lt;&lt; &quot;Author last name: &quot;;
      std::string lastName;
      std::cin &gt;&gt; lastName;
  
      if (lastName.size() != 0) {
          lastName = lastName + &quot;, &quot;;
      }
  
  
      std::cout &lt;&lt; &quot;Author first name: &quot;;
      std::string firstName;
      std::cin &gt;&gt; firstName;
  
      if (firstName.size() != 0) {
          firstName = firstName + &quot;. &quot;;
      }
  
  
      std::cout &lt;&lt; &quot;Article title: &quot;;
      std::string articleTitle;
      getline(std::cin, articleTitle);
  
      if (articleTitle.size() != 0) {
          articleTitle = &quot;\&quot;&quot; + articleTitle + &quot;.\&quot; &quot;;
      }
  
      std::cout &lt;&lt; &quot;Title of web page: &quot;;
      std::string pageTitle;
      std::cin &gt;&gt; pageTitle;
  
      if (pageTitle.size() != 0) {
          pageTitle = pageTitle + &quot;. &quot;;
      }
  
      std::cout &lt;&lt; &quot;Publication date: &quot;;
      std::string publicationDate;
      getline(std::cin, publicationDate);
  
      if (publicationDate.size() != 0) {
          publicationDate = publicationDate + &quot;. &quot;;
  
      }
  
      std::cout &lt;&lt; &quot;Web address: &quot;;
      std::string webAddress;
      getline(std::cin, webAddress);
  
      webAddress = &quot;&lt;&quot; + webAddress + &quot;&gt;. &quot;;
  
      std::cout &lt;&lt; &quot;Date accessed: &quot;;
      std::string dateAccessed;
      getline(std::cin, dateAccessed);
  
      if (dateAccessed.size() != 0) {
          dateAccessed = dateAccessed + &quot;. &quot;;
      }
  
      std::string citation =
          lastName + firstName + articleTitle + pageTitle + publicationDate + webAddress + dateAccessed;
  
      std::cout &lt;&lt; citation; //TEST; remove after
  }
  </code></pre>
  <p>EDIT: I/O</p>
  <pre><code>Leave any unknowns blank.
  Author last name: Doe
  Author first name: John
  Article title: Title of web page: title
  Publication date: Web address: www.win.com
  Date accessed: 4/29/09
  Doe, John. Title. &lt;www.win.com&gt;. 4/29/09. 
  </code></pre>
  <p>As you can see, something is going wrong, because my input is getting skipped over.</p>