Hi everyone,
I'm working on a program for developing files for student marks. My issue is in the else statement. What's happening is that it prints the prompt for the First Name but then prints the prompt for the Last Name without allowing me to input anything. It works fine from that point on, and allows me to input values for all consecutive prompts (not shown here). As far as I can see there is no difference between the First Name prompt and the Last Name prompt, so maybe someone here can spot it?
CheersCode:#include <stdio.h> #include <math.h> #define SIZE 50 int AddStudent(); int AddStudent() { FILE *fptr; char *MyString; int Flag; struct Students { char FirstName[SIZE]; char LastName[SIZE]; char StudentNumber[8]; char Assignments[5][4]; char Labs[5][4]; char Midterm[4]; char Final[4]; }; struct Students GNG1106[200]; fptr=fopen("E://StudentFile.txt", "a+"); if (fptr == NULL) printf("Unable to open file"); else { printf("File was opened"); printf("\nPlease enter the first name of the student: "); gets(GNG1106[0].FirstName); printf("\nPlease enter the last name of the student: "); gets(GNG1106[0].LastName); printf("\nPlease the student's student number: "); gets(GNG1106[0].StudentNumber); } }