title: istream::getline failbit not getting set?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main(){
  
      istringstream input("1234");
  
      char c[5];
  
      while(input.getline(c, 5, '\n')){
          cout &lt;&lt; "OUTPUT: " &lt;&lt; c &lt;&lt; endl;
      }
  
  
  }
  </code></pre>
  
  <p>The output is</p>
  
  <pre><code>OUTPUT: 1234
  </code></pre>
  
  <p>when I feel like all sources tell me <code>input</code> should test as <code>false</code> and there should be no ouput. From the standard (N3337) [27.7.2.3]/18:</p>
  
  <blockquote>
    <p>Effects: Behaves as an unformatted input function (as described in 27.7.2.3, paragraph 1). After constructing a sentry object, extracts characters and stores them into successive locations of an array whose first element is designated by s. Characters are extracted and stored until one of the following
    occurs:</p>
    
    <ol>
    <li>end-of-file occurs on the input sequence (in which case the function calls setstate(eofbit));</li>
    <li>traits::eq(c, delim) for the next available input character c (in which case the input character
    is extracted but not stored);320</li>
    <li>n is less than one or <strong>n - 1 characters are stored</strong> (in which case the function calls setstate(
    failbit)).</li>
    </ol>
  </blockquote>
  
  <p>Since <code>4</code> values get stored, <code>failbit</code> should be getting set. Some other sources give a bit differing but still confusing input on this function. <a href="http://www.cplusplus.com/reference/istream/istream/getline/" rel="nofollow">Cplusplus</a>:</p>
  
  <blockquote>
    <p>The failbit flag is set if the function extracts no characters, or if the delimiting character is not found once (n-1) characters have already been written to s. Note that if the character that follows those (n-1) characters in the input sequence is precisely the delimiting character, it is also extracted and the failbit flag is not set (the extracted sequence was exactly n characters long).</p>
  </blockquote>
  
  <p>Again, the deliminting character <code>'\n'</code> is not found after the <code>4</code>, and so <code>failbit</code> should be getting set. <a href="http://en.cppreference.com/w/cpp/string/basic_string/getline" rel="nofollow">Cppreference</a> says a similar thing. What am I missing here?</p>