Multiple Records


            struct student
            {
                char name[20];
                int rollno, fees;
            };
        
            main()
            {
                struct student s[5];
                int k;
                FILE *fp;
                
                fp = fopen("data.dat", "wb");
        
                if (fp == NULL) 
                {
                    printf("Error opening file!");
                    return;
                }
        
                for(k = 0; k <= 2; k++)
                {
                    printf("Enter the Name : ");
                    scanf("%s", s[k].name);
        
                    printf("\n Enter Roll No. :");
                    scanf("%d", &s[k].rollno);
        
                    printf("\n Enter the Fees : ");
                    scanf("%d", &s[k].fees);
        
                    fwrite(&s[k], sizeof(s[k]), 1, fp);
                }
        
                fclose(fp);
            }
        

Output: