#include <stdio.h>
int main(){
    FILE *fp;
    char name[25];
    int i;
    float cgpa;
    fp = fopen("FileExercise.txt", "w");
    if(fp==NULL) printf("File doesn't exist.\n");
    else{
        printf("File has opened.\n");
        for(i=0; i<5; i++){
            printf("Enter roll-%d student name: ", i+1);
            gets(name);
            fputs(name, fp);
            fprintf(fp, "\t%d", i+1);
            printf("Enter students cgpa: ");
            scanf("%f", &cgpa);
            fprintf(fp, "\t%0.2f", cgpa);
            fprintf(fp, "\n");
        }
        printf("File has written successfully.\n");
    }
    return 0;
}
I was trying to to make a file of students. That includes students name, roll & cgpa. For the 1st students it was working. But from the second student I can't take student name as input also can't write student name in file. Now, What should I do?
