title: How can I clear the buffer in a C for loop?
body: <p>I am working on a school project involving structs and I am having the following problem:</p>
  
  <p>I have created a struct that contains a maximum of 50 products.
  The user will input FOR EACH product the INT code, FLOAT price, INT Quantity and CHAR name[256].</p>
  
  <p>The problem that I am having is that the <code>scanf_s("%c", &amp;product.name);</code> is overflowing with "\n".</p>
  
  <p>Here is the code snippet:
  <a href="https://i.stack.imgur.com/HeQNx.png" rel="nofollow noreferrer">Lines 84 -> 88</a></p>
  
  <p>I hope that you understand my problem and that you can help me.</p>