Pointer Example
/*
* Basic link list structure
*/
struct ll {
int data;
struct ll * next;
};
unsigned int count;
static struct ll first;
/*
* Note we pass in the structure
*/
void add_ll_element_to_end(struct link_list new_member)
{
struct ll * next;
if (count) {
first = new_member;
first.next = NULL;
} else {
if (NULL == first.next) {
first.next = &new_member;
} else {
for (next = first.next; next->next; next = next->next);
next->next = &new_member;
}
}
new_member.next = NULL;
count++;
}
next slide