I'm currently working on a project and I'm having a bit of an hard time with two functions in specific:
Function 1:In this function I want the doctor's number of patients to increase after patient has consulted that doctor.
As so,by means of testing the function,in the menu, I add a doctor to the array of doctors and then I add a patient.In the patient fields that are asked in program(name,age,address), I fill the field name of the doctor with the doctor that
treated/will treat him.
After that,I check the doctor's data and the number of patients has indeed increased by one.
If I add another doctor and add another patient,and in the patient's doctor name field I add the new doctor name,in the doctor's data,instead of just incrmenting the new doctor's patient it increments the new doctor's patient and the other doctor!
void addpatients_to_doctors(Doctors array_of_doctors,Patients array_of_patients,int ndoctors,int npatients)
for(i=0;i<ndoctors;i++) // Goes through array of doctors
for(x=0;x<npatients;x++) // Goes through array of patients
for(z=0;z<array_of_patients[x].nconsultations;z++) // Goes through number of existing consultations
if(strcmp(array_of_doctors[i].p.name, array_of_patients[x].h[z].doctorname)==0) //compares the name in the doctor's file with the name of the doctor in the patient's historic consultations
Function 2:In this function I want the patient's historic to have at a maximum 10 consultations from the oldest in the beggining of the array to the newest. After reaching the 10 consultations, the consultation on pos 1 of array will be copied to pos 0,the consultation from pos 2 to pos 1 and from that forward until it reach the last pos where it will have "today's" consultation.
This all works alright after I reach the 10 consultations.After that it looks like all the historic is erased and it copies the newwest consultation to teh beggining having only that input on the historic.
int keep_data_con(Patients array_of_patients,Doctors array_of_doctors,int npatients)
printf("Input your id:\n");
for(i=0;i<npatients && strcmp(nid,array_of_patients[i].p.npid)!=0; i++);
printf("Patient doesn't exist\n");
Any help on this is very appreciated!Thanks in advance!