Reference parameter can they be done in C?
As in:
I have struct:
Now I'm trying (trying being the operative word here) to write a Pop() (which obviously has to remove the last Node and return the info of it) function:
Say I call it by:
I know in C++ I would be sending the _node as a reference parameter thus when I change it here 'new' would also change. Here however if you GDB it _node changes but it doesn't affect 'new'. How can I do that?
As in:
I have struct:
Code:
typedef struct listNode listNode; struct listNode { struct listNode *forLink; struct listNode *bacLink; struct listNode *firLink; char *info; };
Code:
char *listPop(listNode *_node) { char *temp; listNode *curLink = _node->firLink; while (curLink->forLink) curLink->forLink; temp = curLink->info; _node = curLink->bacLink; //THE PROBLEM return temp; }
Code:
n = listPop(new); //where new is a listNode obviously.
Comment