title: Difference between fgets and gets
body: <p>What is the difference between <code>fgets()</code> and <code>gets()</code>?</p>
  
  <p>I am trying break my loop when the user hits just "enter".  It's working well with <code>gets()</code>, but I don't want to use <code>gets()</code>.
  I tried with <code>fgets()</code> and <code>scanf()</code> but I don't have the same results as with <code>gets()</code>. <code>fgets()</code> breaks the loop whatever user enters in text! Here is my code : </p>
  
  <pre><code>void enter(void)
  {
    int i,
  
    for(i=top; i&lt;MAX; i++)
      {
        printf(".&gt; Enter name (ENTER to quit): ");
        gets(cat[i].name);
  
        if(!*cat[i].name)
           break;
  
        printf(".&gt; Enter Last Name: ");
        scanf("%s",cat[i].lastname);
        printf(".&gt; Enter Phone Number: ");
        scanf("%s",cat[i].phonenum);
        printf(".&gt; Enter e-Mail: ");
        scanf("%s",cat[i].info.mail);
        printf(".&gt; Enter Address: ");
        scanf("%s",cat[i].info.address);
        printf("\n");
      }
    top = i;
  }
  </code></pre>