Hello,
I'm having a lot of trouble implementing a linked-list style stack in C. I am getting the following compiler error:
Code:
stack.c:28: error: request for member "data" in something not a structure or union.
I know what you're thinking... he used a '.' when he should have used a '->'. I don't think that this is my problem in this case, as I have attempted to compile with every combination in a "stab in the dark" debugging style (haha). Here is the code:
Code:
char* pop (stack_t *stack) {
...
node *back;
back = stack->back;
...
char *return_val;
return_val = back->data; //the line causing the error
...
}
Here is the defenition for stack_t and node:
Code:
typedef struct node *node; //so I can use self referencing structure members
struct node {
node *next;
node *prev;
char *data;
};
typedef struct {
node* front;
node*back;
int size;
} stack_t;
Can anyone help me out?