My program adds a name and age attribute to a list of PERSONS. I'd like to have a function that passes the "first" and "last" pointer to this list. From here, I wanted the program to start from the first pointer and add that age to the next, and the next, until the last pointer is reached.
For example, if my list were:
Jane (36 yrs), Bob (14 yrs), Rachel (10 yrs)
I want it to sum up 36 + 14 + 10 = 60
Please help!
So far, i have the function prototype to be
int total_age(person **f, person **l)
{
int sum=0;
person *temp;
sum = sum + person->age;
}
How do I run through each person.age value for from first to last?