title: Effect of noskipws on cin>>
body: <p>As I understand, the extraction operator skips the whitespace in the beginning and stops upon encountering a whitespace or end of stream. noskipws can be used to stop ignoring the leading whitespaces.</p>
  
  <p>I have the following program where I have used noskipws.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      char name[128];
  
      cout&lt;&lt;"Enter a name ";
      cin&gt;&gt;noskipws&gt;&gt;name;
      cout&lt;&lt;"You entered "&lt;&lt;name&lt;&lt;"\n";
  
      cout&lt;&lt;"Enter another name ";
      cin&gt;&gt;name;
      cout&lt;&lt;"You entered "&lt;&lt;(int)name[0]&lt;&lt;"\n";
  
      return 0;
  }
  </code></pre>
  
  <p>My queries are: </p>
  
  <ol>
  <li><p>If I enter "John" as the first input, then the second cin>> operation does not wait for input and does not copy anything to the destination i.e. the name array. I expected second cin>> to transfer at-least a newline or end of stream, instead of just setting the destination string to empty. Why is this happening ?</p></li>
  <li><p>The same thing is observed when I enter "John Smith" as the input for first cin>> statement. Why doesn't the second cin>> statement copy the space or "Smith" to the destination variable ? </p></li>
  </ol>
  
  <p>Following is the output of the program:</p>
  
  <pre><code>Enter a name John
  You entered John
  Enter another name You entered 0
  
  
  Enter a name John Smith
  You entered John
  Enter another name You entered 0
  </code></pre>
  
  <p>Thanks!!!</p>