title: How can I make each scanf working without skip
body: <blockquote>
  <p>I make the loop with gets and scanf. Actually I make the space for newline buffer. so I think each scanf works but when I input value to &amp;books[ctr].cost compiler skip next 3 questions. I don't know why It work like this</p>
  </blockquote>
  <p>books is structure variable</p>
  <pre><code>for (ctr = 0 ; ctr &lt; 3 ; ctr++)
  {
      printf(&quot;What is the name of the book #%d?\n&quot;, (ctr+1));
      gets(books[ctr].title);
      puts(&quot;Who is the author?  &quot;);
      gets(books[ctr]. author);
      puts(&quot;How much did the book cost?  &quot;);
      scanf(&quot;  $%f&quot;, &amp;books[ctr].price);
      puts(&quot;How many pages in the book?  &quot;);
      scanf(&quot;  %d&quot;, &amp;books[ctr].pages);
      getchar( );
  }
  printf(&quot;\n\n Here is the collection of books : \n&quot;);
  for (ctr = 0 ; ctr &lt; 3 ; ctr ++)
  {
      printf(&quot;#%d: %s by %s&quot;, (ctr+1), books[ctr].title, books[ctr].author);
      printf(&quot;\n It is %d pages and costs $%.2f&quot;, books[ctr].pages, books[ctr].price);
      printf(&quot;\n\n&quot;);
  }
  
  return 0;
  </code></pre>
  <p>}</p>