I am trying to work a through a computer science course on coursebuffet.com, which referred me to saylor.org, which gave me this to learn about how to implement a stack with a linked list in C.
First, I think I understood the concept, but if you'd be so kind and scroll down in the link you will find at the end of it a link to a main file, with which you should test your implementation of it. And what absolutely baffles me for the last two days (yeah, that's how much time I already sank in this one problem) is the following passage:
/*
* Initialize the stack. Make it at least
* big enough to hold the string we read in.
*/
StackInit(&stack, strlen(str));
I can't understand how to initialise a linked list. I mean, that's against its concept, isn't it? I would need to create struct Elements before filling them with push commands, but if I do that, I need to follow the stack in two directions. One directions for pushing it and the opposite direction for popping it. That would need two pointers. I thought the whole concept as described here would be one data element and one pointer per ADT-unit.
Can someone please explain this to me?