Hi everyone I am trying to make student records system and write all the information that the user has typed into a text file. This is my attempt. It runs without any errors but when i go to check the text file nothing is written inside Please help !
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_STUDENT 20

struct file {
    int year_of_stud,sem;
    char name[40],gender,programme,student_id[15];
    double fee;
}Student[MAX_STUDENT];

int main(void)
{
    FILE *file;
    char ans='Y';
    int count = 0;
    int i=0;
    file = fopen ("Student.txt", "w");

    printf("How many students do you wish to add? ");
    scanf("%d", &count);
    getchar();
    //count = MAX_STUDENT;
    fflush(stdin);






    for(i=0;i<count;i++)
{

    printf("Student #%d\n",i+1);
    printf("===========\n");
    printf("Enter Student ID : \n");
    scanf("%[^\n]", Student[i].student_id);
    fflush(stdin);
    printf("Please enter the student's name : \n");
    scanf("%[^\n]", Student[i].name);
    fflush(stdin);
    printf("Enter Gender : \n");
    scanf("%c", &Student[i].gender);
    fflush(stdin);
    printf("Enter Programme Enrolled In : \n");
    scanf("%s", &Student[i].programme);
    fflush(stdin);
    printf("Enter Year of Study : \n");
    scanf("%d", &Student[i].year_of_stud);
    printf("Enter Current Semester : \n");
    scanf("%d", &Student[i].sem);
    printf("Enter Fee's of Course : \n");
    scanf("%lf", &Student[i].fee);
    fflush(stdin);
    }

    if(i == 0)
            {
                //count = i;

                for(i=0; i<count; i++)
                {
                    fprintf(file, "Student #%d\n", i+1);
                    fprintf(file, "-------------\n");
                    fprintf(file, "%s\n", Student[i].student_id);
                    fprintf(file, "%s\n", Student[i].name);
                    fprintf(file, "%c\n", Student[i].gender);
                    fprintf(file, "%s\n", Student[i].programme);
                    fprintf(file, "%d\n", Student[i].year_of_stud);
                    fprintf(file, "%d\n", Student[i].sem);
                    fprintf(file, "%.2lf\n\n", Student[i].fee);
                }
            }

            fclose(file);
    

    return 0;


}