prototype:
In main:Code:struct stack pop (struct stack ** tos);
function definition:Code:if (tos == NULL) { printf ("stack empty!\n"); }else { struct stack temp = pop(&tos); printf("%d popped.\n", temp.sdata); }
Where did I go wrong with this? I can't quite figure it.Code:struct stack pop (struct stack ** tos) { //holds the return value (data) struct stack temp; //use to free the head node struct stack **freep = tos; //reposition the head of the stack for post pop if((*tos)->next != NULL) *tos = (*tos)->next; //get data value temp = **freep; //free head node free(*freep); return temp; }



LinkBack URL
About LinkBacks



well it looks like you've worked it out anyway. I did do something pretty similar (albeit with some minor differences in structure), but I won't bother posting the code now. Good job Troll_King.