Ok, I'm working with using member functions in structures in C, which I've never done before, and I'm stuck. Here's the code:
typedef struct Node
{
char data;
struct Node* next;
}node,*node_ptr;
typedef struct stack
{
node* head;
int length;
void (*push)(char,node_ptr);
char (*pop)(node_ptr);
}stack,*stack_ptr;
void push(char info,node_ptr head)
{
node_ptr current;
current=(node *)malloc(1);
current->data=info;
current->next=head;
head=current;
}
char pop(node_ptr head)
{
node_ptr current;
char input;
input=head->data;
head=head->next;
free(current);
return(input);
}
Now my problem is that I don't want to have to reference a node as a variable to push and pop, I want to use the head of the stack as the only node they will modify. How would I go about doing this?