I'm experimenting with fgets because I heard it's better for dealing with memory buffer overflow but I am not sure of the sizeof component and how to the stdin part helps it to work. Is METHOD 1 or METHOD 2 in the following code the correct implementation of sizeof and what does stdin do exactly in the fgets.
// Data Structure
typedef struct{
char first_name[20];
char middle_name[20];
char last_name[20];
char illness_type[5];
int patient_number;
char doctor_fname[20]; // Doctor's First Name
char doctor_lname[20]; // Doctor's Last Name
char emer_fname[20]; // Emergency Contact's First Name
char emer_lname[20]; // Emergency Contact's Last Name
int emer_telephone; // Emergency Contact's Number
} PATIENT_DATA;
// Defining data type
PATIENT_DATA section_1[40]={"","","","",0,"","","","",0};
//METHOD 1
printf("\nPatient First Name: ");
fflush(stdin);
fgets(section_1[tally1].first_name, sizeof section_1[tally1].first_name, stdin);
//METHOD 2
printf("\nPatient First Name: ");
fflush(stdin);
fgets(section_1[tally1].first_name, sizeof section_1[20].first_name, stdin);