Alright guys, so I know how the pop function works obviously. I also know that I need to set a LinkNode * top = head and that if top == NULL that you need to return NULL. I’m just not sure what I’m honestly supposed to do after that. The return is supposed to remove and return a value and the data type of the function is a pointer.
I’m not going to post my code on here unless people are honestly going to help me out because I’ve already been criticized greatly once and it was quite discouraging. :\
Well, the things you mention have nothing to do with
pop.For a linked list,
popis about unlinking the first node. Depending on the level of abstraction the function might return (a pointer to) that node, or the node’s “value”, or nothing. At the lowest level of abstraction you want just the unlink functionality, which can go like this:Then, as an example, a
popthat destroys the node goes like this:while a
popthat returns the value in the node goes like this:A subtle point here is whether the value is guaranteed to be copied before the node is destroyed. I’m just assuming it is. I leave it to the lawyers to find the standardese for that.
Cheers & hth.