Okay, there's no way I'm posting three big files of code from a textbook (for all the obvious reasons). This is not a class I'm taking; I'm trying to learn C programming on my own.
I've spent over five days working on ONE FREAKING EXERCISE. I'm a stubborn person, but I'm getting close to quitting the whole process due to some apparent genetic disability that prevents me from understanding this particular exercise. I feel like I'm missing one piece of vital information regarding pointers that I never properly learned from the textbook (my fault, not the textbook's). It's pushing me past the edge of patience because I can't even figure out the proper way to frame the question for this forum. I'll try one more time...
The exercise includes an already working program that identifies two structures:
Then, the point of the exercise is for me to rewrite a bunch of functions that have been referencing List, but AFTER the definition of List is changed to this:Code:struct film { char title[TSIZE]; int rating; }; typedef struct film Item; typedef struct node { Item item; struct node * next; } Node; typedef Node * List;
What I'm running up against seems to be a basic misunderstanding of levels of pointers. I acknowledge that the new definition of List changes what was once a 'pointer to a structure' to a 'structure with two pointers to a structure'. I understand (or thought I did) the difference between a pointer and a non-pointer structure member.Code:// typedef Node * List; // removed for redefinition typedef struct list { Node * head; /* points to head of list */ Node * end; /* points to end of list */ } List;
No matter how many times I start over again, and try to re-write the functions that utilize List, I come up with crap. I've used print statements to follow my progress line by line. The closest I could come was a list of node members that were always off by two. And forget about the memory freeing function... at this point I can't even dream of making that work.
As there seems to be no formal question in this post, and a lot of whiny blathering, I'm not sure if anyone will be able to help. I don't want an "answer" to the exercise from the forum, I want to fully understand the concept in this program's scenario. I just wish I could figure out how I could properly frame the question to gain the missing information I need, in order to not feel like a complete moron.