I am trying to write a function that will return the list of family members given the family name.

I want to pass the family name as an input (char array) and I want to return two arrays of strings that will return family member “roles” and their names. For example, if I pass the argument “McCoys” it will return something like:
familyMemberRoles = {‘Dad’, ‘Mom’, ‘Son’, ‘Daughter’};
familyMemberNames = {‘John’, ‘Jane’, ‘James’, ‘Jill’};

Let’s say I will have a main function and a function ‘getFamilyMembers’. There is some data structure that the function getFamilyMembers will access to get the info for me. So something like this:
Code:
void getFamilyMemberNames (const char *familyName, char ** familyMemberRoles, char ** familyMemberNames)
{
	// Get the data here to populate familyMemberRoles, and familyMemberNames
}

int main ()
{

char *familyMemberRoles[];
char *familyMemberNames[];

getFamilyMembers(“McCoys”, familyMemberRoles, familyMemberNames )

// Do something with the info received

return 0;
}
Here are my questions:

  1. How do I initialize the arrays familyMemberRoles and familyMemberNames in the main function if I don’t know what their size will be? For example, some family can have more than 2 children so how would I initialize this and pass it to a function? And how do I “resize” the arrays in the function getFamilyMembers?
  2. Am I passing the variables familyMemberRoles, and familyMemberNames by reference correctly or do I do this differently?
  3. What is the best way of checking if the family is not found and the two arrays familyMemberRoles, and familyMemberNames are NULL?


Sorry, these might be very fundamental questions but I am new to C++. I would appreciate any help!

Alisha