Multiple Records Read Write


            #include<stdio.h>
            #include<conio.h>
        
            struct student
            {
                char name[20];
                int rollno, fees;
            };
        
            main()
            {
                struct student s[5];
                int k;
                FILE *fp;
        
                fp = fopen("data.dat", "rb");
                clrscr();
        
                for(k = 0; k <= 2; k++)
                {
                    fread(&s[k], sizeof(s[k]), 1, fp);
                    printf("Name : %s", s[k].name);
                    printf("\n Roll No : %d", s[k].rollno);
                    printf("\n Fees : %d", s[k].fees);
                }
        
                getch();
            }
        

Output: