I have an array of structures and the structure looks as below:
struct patient {
int pictures[2];
int personal_number;
char patient_name[FILE_PATIENT_NAMES + 1];
int num_of_matches;
};
typedef struct patient Patient;
Patient patientregister[5];
I have two functions as down below:
/********* function declaration *********/
Patient *search_patient(Patient patientregister[], int num_of_patients);
Patient *search_by_personaNumber(Patient *matches[],
Patient patientregister[], int num_of_patients);
The code starts from *search_patient and then goes to *search_by_personalNumber. *search_patient has another array of structures declared inside it: Patient matches[5]; and the idea is to send a pointer of Patient matches[5]; to *search_by_personalNumber. and then get it back to *search_patient with the matches the user is searching for. My question is how to send a pointer of an array of structures to another function, use the pointer to fill in the array of structures and send the pointer back to the original function, in my case *search_patient?
Patient *matches[]will never be compliant an argument fromPatient matches[5]in any way whatsoever. Either the argument, or the formal parameter has to change somehow. Regardless, as we have no idea what this code is even supposed to be doing, we can't honestly assist further than pointing out that non-trivial fact. I suspect you're confusing a "pointer to an array of structures" with an "array of pointers to structures", but the fog is pretty thick to make that wild assumption.