הנה מה שעשיתי
#include <stdio.h> #define NUM_OF_P 25//mispar cholim char getcode(); void print_cholim(); struct cholim *imut_cholim(struct cholim chole[],int ID); struct cholim *imut_cholim(struct cholim chole[],int ID); struct cholim { int id; char adrress[28]; char p_name[25]; char sex; int b_date; char p_state; }; /*ata zarich lhagdir po struct cholim Cholim[NUM_OF_P]={ {lhacnis pratim} }; */ void main() { struct cholim *p; char code; int temp_id=0; while((code=getcode()) !='E') { switch(code) { case 'P': print_cholim(&p); break; case 'B': printf("Enter the ID"); scanf("%d",&temp_id); p=imut_cholim(Cholim,temp_id); break; case 'S' //printf("Sorting..."); tase miun buot ragil(buuble sort) } } printf("Program Ended!!\n"); } void print_cholim(struct cholim *p) { int i; for(i=0;i<NUM_OF_P;++i) { printf("%9d %28s %25s %s %6d %s",p.id,p.adrress,p.p_name,p.sex,p.b_date,p.p_state); } } void print_metim(struct cholim *p) { int i=0; printf("The patientes that died from the desiese"); for(i=0;i<NUM_OF_P;++i) { if(p->p_state =='X') { printf("%9d %28s %25s %s %6d %s",p.id,p.adrress,p.p_name,p.sex,p.b_date,p.p_state); } } } struct cholim *imut_cholim(struct cholim chole[],int ID) { struct cholim *ptr; for (ptr=chole;ptr->id !=ID;++ptr) ; if(ptr->p_state =='X') { printf("The patient is dead = 1"); } else { printf("The patient is still alive = 0"); } return(ptr); } //Bdikat tkinut shel sug hapeula /* P=Print shel kol hacholim D=print shel kol mishe niftar B=imut cholim(mi she chole bmaza beinoni vmala) E=Exit S=sort */ //Function that gets character from the input and check if its legal char getcode() { char c,ok; do{ c=getchar(); ok=(c=='P')||(c=='D')||(c=='B')||(c=='E')||(c=='S'); if(!ok) printf("%c is unknown code,try again\n",c); }while(!ok); return(c); }