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:
#include <stdio.h>
#include <stdlib.h>
struct films {
char title[100];
int length;
char genre[100];
};
int main() {
int n;
scanf("%d",&n);
struct films film[100];
for (int i=0; i<n; i++) {
printf("%d. film:\n", i+1);
printf("Title: ");
fgets(film[i].title,100,stdin);
printf("Lenght: ");
scanf("%d",&film[i].length);
printf("Mufaj: ");
fgets(film[i].genre,100,stdin);
}
printf("The films: \n");
for (int i=0; i<n; i++)
printf("The %d.film:[%s:%d:%s] ", i+1 , film[i].title, film[i].length, film[i].genre);
return 0;
}
I made a mistake at fgets
, but I don't know what should I do to make it right.
Can somebody help me?