Code:#include <stdio.h> #include <stdlib.h> #include <conio.h> #include<windows.h> #include <string.h> int main() { FILE *fp, *ft; char another, choice; struct student { char student_name[30]; char matrix_number; char group[20]; char cocuricular_activities[15]; char lecturer_name[20]; char position[20]; int marks; int attendance; }; struct student stu; char student_name[30]; long int recsize; fp = fopen("STUDENT.DAT","rb+"); if(fp == NULL) { fp = fopen("STUDENT.DAT","wb+"); if(fp == NULL) { printf("Cannot open file"); exit(1); } } recsize = sizeof(stu); while(1) { system("cls"); printf("\n***Cocuriculum Activities Record System***"); printf("\n1.Add Record\n"); printf("\n2.Search Record\n"); printf("\n3.Edit Record\n"); printf("\n4.List Record\n"); printf("\n5.Delete Record\n"); printf("\n6.Exit\n"); printf("\n Please make your choice :"); scanf("%d",&choice); fflush(stdin); choice = getche(); switch(choice) { case'1': system("cls"); fseek(fp,0,SEEK_END); another = 'y'; while(another == 'y') { printf("\n Name: "); scanf("%s",stu.student_name); printf("\n Matrix number : "); scanf("%d",&stu.matrix_number); printf("\n Group: "); scanf("%s",&stu.group); printf("\n Cocuricular activities: "); scanf("%s",&stu.cocuricular_activities); printf("\n Lecturer Name: "); scanf("%s",&stu.lecturer_name); printf("\n Position: "); scanf("%s",&stu.position); printf("\n Marks: "); scanf("%f",&stu.marks); printf("\n Attendance: "); scanf("%d",&stu.attendance); fwrite(&stu,recsize,1,fp); printf("\n Add new reocrd(y/n) "); fflush(stdin); another = getche(); } break; case'2': system("cls"); rewind(fp); while(fread(&stu,recsize,1,fp)==1) { printf("\n Matrix number: "); scanf("%d",&stu.matrix_number); } break; case'3': system("cls"); choice = 'y'; while(choice == 'y') { printf("\n Enter student name to edit record: "); scanf("%s", student_name); rewind(fp); while(fread(&stu,recsize,1,fp)==1) { if(strcmp(stu.name,student_name) == 0) { printf("\n Enter new student name: "); scanf("%s",stu.student_name); printf("\n Enter new matrix number: "); scanf("%d",stu.matrix_number); printf("\n Enter new group: "); scanf("%s",stu.group); printf("\n Enter new cocuricular activities: "); scanf("%s",stu.cocuricular_activities); printf("\n Enter new lecturer name: "); scanf("%s",stu.lecturer_name); printf("\n Enter new position: "); scanf("%s",stu.position); printf("\n Enter new marks: "); scanf("%f",stu.marks); printf("\n Enter new attendance"); scanf("%d",stu.attendance); fseek(fp,-recsize,SEEK_CUR); fwrite(&stu,recsize,1,fp); break; } } printf("\n Edit another record(y/n)"); fflush(stdin); another = getche(); } break; case'4': system("cls"); rewind(fp); while(fread(&stu,recsize,1,fp)==1) { printf("\n %s,name.stu"); printf("\n %d,matrix_number.stu"); printf("\n %s,group.stu"); printf("\n %s,cocuricular_activities.stu"); printf("\n %s,lecturer_name.stu"); printf("\n %f,marks.stu"); printf("\n %d,attendance.stu"); } getch(); break; case'5': system("cls"); another = 'y'; while(another == 'y') { printf("\n Enter name of student to delete record: "); scanf("%s",student_name); ft = fopen("temp.dat","wb"); rewind(fp); while(fread(&stu,recsize,1,fp) == 1) { if(strcmp(stu.name,student_name) != 0) { fwrite(&stu,recsize,1,ft); } } fclose(fp); fclose(ft); remove("STUDENT.DAT"); rename("Student.dat","STUDENT.DAT"); fp = fopen("ESTUDENT.DAT", "rb+"); printf("Delete another record(y/n)"); fflush(stdin); another = getche(); } break; case'6': fclose(fp); exit(0); } } return 0; }