title: User input(cin) - Default value
body: <p>I can't figure out how to use a "default value" when asking the user for input. I want the user to be able to just press Enter and get the default value. Consider the following piece of code, can you help me?</p>
  
  <pre><code>int number;
  cout &lt;&lt; "Please give a number [default = 20]: ";
  cin &gt;&gt; number;
  
  if(???) {
  // The user hasn't given any input, he/she has just 
  // pressed Enter
  number = 20;
  
  }
  while(!cin) {
  
  // Error handling goes here
  // ...
  }
  cout &lt;&lt; "The number is: " &lt;&lt; number &lt;&lt; endl;
  </code></pre>