Issue obtaining string input with a space using getline()
<p>My code is:</p>

<pre><code>char structure[10];
char name[20];
double weight;

cout &lt;&lt; "Enter structure : ";
cin &gt;&gt; structure;

if (strcmp(structure, "0") != 0) {

cout &lt;&lt; "Enter name : ";
cin.getline(name, 20);
cout &lt;&lt; "Enter weight : ";
cin &gt;&gt; weight;

}
</code></pre>

<p>It's fine up to the cout &lt;&lt; "Enter name : " part. I can enter the structure and then it prints out "Enter name:" but skips the input part, and skips to the weight input. the output looks something like.</p>

<pre><code>Enter structure : h20
Enter name :  Enter weight : 2

Enter structure : 
</code></pre>

<p>It just skips the input part for name. Anyone know what the problem is?</p>
