title: Detect a newline character with getline or istringstream
body: <p>In my program, I'm asking the user for input via getline, and then in a separate class, splitting the string into three different strings which I will then check via a list of pre-determined values.</p>
  
  <p>The way it works now, if someone enters an invalid command, I display "INVALID"</p>
  
  <p>The problem I'm having is with a string containing only spaces or only a single newline character.</p>
  
  <p>Here is what I'm trying to do:</p>
  
  <pre><code>std::string command; // command user enters
  getline(std::cin, command); // user input here
  
  std::string tempCheck; // if we have a value in here other than empty, invalid
  // use istringstream to grab the words, max of 3
  std::istringstream parse{fullCommand}; // parse command into words
  
  if(fullCommand.empty()){ // nothing has been input
      std::cout &lt;&lt; "INVALID" &lt;&lt; std::endl;
      return;
  }
  
  parse &gt;&gt; command; // stores first word (the command)
  parse &gt;&gt; actionOne; // stores second word as parameter
  parse &gt;&gt; actionTwo; // stores third word as parameter
  parse &gt;&gt; tempCheck;
  
  if(!tempCheck.empty()) {
      std::cout &lt;&lt; "INVALID" &lt;&lt; std::endl;
      return;
  }
  </code></pre>
  
  <p>The variable tempCheck basically means that if it goes over three words (the limit I want for commands), then it is INVALID. I also thought that having an empty string would work, but it just ends up in an infinite loop when nothing is input, but I just hit enter.</p>
  
  <p>Here is what I expect my input to be doing (bold is output):</p>
  
  <pre><code>CREATE username password
  **CREATED**
        LOGIN          username password
  **SUCCEEDED**
  ASDF lol lol
  **INVALID**
  
  **INVALID**
  REMOVE username
  **REMOVED**
  
  **INVALID**
  QUIT
  **GOODBYE**
  </code></pre>
  
  <p>Here is what is happening:</p>
  
  <pre><code>CREATE username password
  **CREATED**
   // newline entered here
  </code></pre>
  
  <p>And it goes into a seemingly infinite loop. I can still type things, however, they don't actually affect anything. For example typing QUIT does nothing. But, if I restart my program and just type "QUIT" without trying to only use a newline character or only use a space, I get the expected output:</p>
  
  <pre><code>QUIT
  **GOODBYE**
  </code></pre>
  
  <p>So, how do I tell either getline, or my istringstream, that if a user just enters a bunch of spaces and then hits enter, OR if the user just hits enter, display invalid and return? And is there anyway to do this with just getline or istringstream?</p>