Why can't I fill the structure in C?

Task:
To define a structure with three fields, create an array of 7 elements of type of this structure, populate it and display. Faced with the problem: in the structure of 3 fields: two of them of type char, one of type int. When filling out fields of type char, I use the function fgets(), to fill in the int use the normal scanf(), in this case, after filling the first element of an array of structures, I skipped filling the first field of the next element of the array... Here's how it looks:
c643c4de47d84004a5a6c2f2908e4888.png
Here is the code of the program itself:
#include <stdio.h>
#include <stdlib.h>

aeroflot struct{
 nazn char[20];
 char tip[20];
 int numr;
};
int main(){
 int i;
 struct aeroflot airport[7];
 for( i = 0; i < 7; i++ ){
 printf("Enter #%d flight nazn: ", i);
 fgets(airport[i].nazn, 20, stdin);
 printf("Enter #%d flight tip: ", i);
 fgets(airport[i].tip, 20, stdin);
 printf("Enter #%d flight numr:", i);
 scanf("%d", &airport[i].numr);

 printf("You entered:\n");
 fputs(airport[i].nazn, stdout);
 fputs(airport[i].tip, stdout);
 printf("\n%d", airport[i].numr);
}

 return 0;
}</stdlib.h></stdio.h>

Help to understand what the problem is and explain how to fill a field of int in such situations... May need to use other f-tsii?
July 8th 19 at 16:34
4 answers
July 8th 19 at 16:36
Try to clear the buffer at the end of the block in a loop:
fflush(stdin)
where in the program? - lewis_McLaughlin59 commented on July 8th 19 at 16:39
Crutch and undefined behavior - charity84 commented on July 8th 19 at 16:42
July 8th 19 at 16:38
Correct 2 lines:
scanf("%d", &airport[i].numr);
// =>
scanf("%d\n", &airport[i].numr);

printf("\n%d", airport[i].numr);
// =>
printf("%d\n", airport[i].numr);
it's still not working... - lewis_McLaughlin59 commented on July 8th 19 at 16:41
July 8th 19 at 16:40
This is the old andsurasenathe RT use format string, helped me to understand this article and man scanf
July 8th 19 at 16:42
Use fgets() + sscanf(). Using fgets() to get each line and using sscanf() get from it the desired value.

Find more questions by tags C