 <p>You're better off using <a href="http://www.cplusplus.com/reference/string/string/getline/" rel="nofollow"><code>getline</code></a></p> <pre><code>string line; cin.getline(line); </code></pre> <p>It will do nice stuff for you like resizing it.</p>