title: C program with struct and fgets
body: <p>I want to make a program with struct which prints out the data of a film entered by the user.  The program looks like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct films {
    char title[100];
    int length;
    char genre[100];
  };
  
  int main() {
    int n;
    scanf("%d",&amp;n);
  
    struct films film[100];
    for (int i=0; i&lt;n; i++) {
      printf("%d. film:\n", i+1);
      printf("Title: ");
      fgets(film[i].title,100,stdin);
      printf("Lenght: ");
      scanf("%d",&amp;film[i].length);
      printf("Mufaj: ");
      fgets(film[i].genre,100,stdin);
    }
    printf("The films: \n");
    for (int i=0; i&lt;n; i++)
      printf("The %d.film:[%s:%d:%s] ", i+1 , film[i].title, film[i].length, film[i].genre);
    return 0;
  }
  </code></pre>
  
  <p>I made a mistake at <code>fgets</code>, but I don't know what should I do to make it right. </p>
  
  <p>Can somebody help me?</p>