#include #include #include #include //============================================================================ struct crs { char name[20]; int unit; float score; }; //============================================================================ struct stude { int id; char name[20]; char family[30]; int course_count; crs lession[10]; char address[100]; }; //========================================================================= int add_record(void); void print_log(stude x); stude search_by_id(int id); float cale_avg(stude x); int select_unit(int id); char menu(void); //========================================================================= void main () { int i,x; stude s1; for(;;) { switch(menu()) { case '1': i= add_record(); if (i==0) cout<<"\n can not add record:"; break; case '2': cout<<"\n enter your ID :"; cin>>x; i=select_unit(x); if (i==0) cout<<"\n can not add record:"; break; case '3': cout<<"\n enter your id: "; cin>>x; s1=search_by_id(x); print_log(s1); break; case '4': return; }// END switch }// End Of FOR }// ENd main //========================================================================= int add_record (void) { stude s1; FILE *f1; f1=fopen("stude.dat","a"); if (f1==0) return(0); cout<<"\n enter stude ID: "; cin>>s1.id; cout<<"\n enter name :"; gets(s1.name); cout<<"\n enter family :"; gets(s1.family); cout<<"\n enter address: "; gets(s1.address); fwrite(&s1,sizeof(stude),1,f1); fclose(f1); } //========================================================================= void print_log(stude x) { int i; float avg=cale_avg(x); cout<<"\n id ="<'4')); return(ch); }// end menu