the problem is that when i only put 1 gets(); in the "Enter Student Number' portion,
it skips right away and proceeds to getting the Students name:
u can run it if ud like to see the problem....
P.S.... the for loop to fine empty slot,.... i dont know what im doing there ! xD haha sorry
Code:
void add_student(student accounts[20], FILE *file)
{
int free;
int i;
for(i = 0; i < 20; i++)
{
if(accounts[i].stud_num == NULL)
{
free = i;
}
}
printf("--------------------------------------------------------");
printf("\n\nEnter student information:\n\n");
printf("\nStudent Number [which will be the accounts username]:\n\n");
gets(accounts[free].stud_num); //i dont know why putting 2 gets(); here works, while only 1 doesnt...
gets(accounts[free].stud_num);
fprintf(file, "%s", accounts[free].stud_num);
fputs("\n", file);
printf("\nName:\n\n");
gets(accounts[free].name);
fprintf(file, "%s", accounts[free].name);
fputs("\n", file);
printf("\nNickname:\n\n");
gets(accounts[free].nick);
fprintf(file, "%s", accounts[free].nick);
fputs("\n", file);
printf("\nBirthdate:\n\n");
gets(accounts[free].bday);
fprintf(file, "%s", accounts[free].bday);
fputs("\n", file);
printf("\nCourse:\n\n");
gets(accounts[free].course);
fprintf(file, "%s", accounts[free].course);
fputs("\n", file);
printf("\n\nAccount creation successful.\n");
}