How do the puts and gets functions work?
<pre><code>main()
{
char name[20];

printf("enter your name\n");

scanf("%s",name);       
printf("%s",name);

gets(name);
puts(name);
}
</code></pre>

<blockquote>
  <p>input:  Sampad Saha</p>
</blockquote>

<p>Output </p>

<blockquote>
  <p>Sampad Saha</p>
</blockquote>

<p>Here puts only uses the input taken from <code>gets()</code>.</p>

<p>as, if I omit this <code>printf()</code> the output would be </p>

<blockquote>
  <p>Saha</p>
</blockquote>

<p>So here puts does not print anything given through <code>scanf()</code>.</p>

<pre><code>main()
{
char color[20];

printf("enter your name\n");

scanf("%s",color);   
puts(color);
}
</code></pre>

<p>But here <code>puts()</code> uses the input taken from <code>scanf()</code> also.</p>