#include #include struct int_list_item { int number; // 4 bytes struct int_list_item *next; // 8 bytes }; void add_number(struct int_list_item *list, int number){ struct int_list_item *place = list; for(; place->next; place = place->next); place->next = malloc(sizeof(struct int_list_item)); // I'm not going to write "fourth" place->next->number = number; place->next->next = 0; } int main(){ struct int_list_item first; first.number = 12; struct int_list_item second; first.next = &second; second.number = 51; second.next = 0; struct int_list_item *third = malloc(sizeof(struct int_list_item)); third->number = 67; third->next = 0; second.next = third; third->next = malloc(sizeof(struct int_list_item)); // I'm not going to write "fourth" third->next->number = 110; third->next->next = 0; add_number(&first, 240); add_number(&first, 310); add_number(&first, 435); // Let's print them out! for(struct int_list_item *place = &first; place; place = place->next){ printf("%d (stored at address %p)\n", place->number, &place->number); } for(struct int_list_item *place = third; place;){ struct int_list_item *tofree = place; place = place->next; free(tofree); } }