I have the following program detail that I need help with. The personCompareByName and personCompareByAge is working fine, I just need to put these two together to work by comparing the names first by age and then by name. I can't figure out what to write in the last line of the personCompareByAgeAndName function. I need to use the a and b variables I just can't seem to figure out how. Thank you all in advance for your help, it's greatly appreciated!
Mod edit: code tags
C:
int personCompareByName(const struct Person *a, const struct Person *b){
if(!a&&!b)
return 0;
if(!a)
return 1;
if(!b)
return -1;
return strcmp(a->name, b->name);
}
int personCompareByAge(const struct Person *a, const struct Person *b){
if(!a&&!b)
return 0;
if(!a)
return 1;
if(!b)
return -1;
return a->age-b->age;
}
int personCompareByAgeAndName(const struct Person *a, const struct Person *b){
if(!a&&!b)
return 0;
if(!a)
return 1;
if(!b)
return -1;
if(a->age-b->age !=0)
return a->age-b->age;
personCompareByName(...);
}
Last edited by a moderator: