#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <aygshell.h>
typedef struct node tnode;
typedef struct node* nodeptr;
struct node
{ int node_id;
nodeptr prev;
};
nodeptr talloc(void)
{ return( (nodeptr)malloc(sizeof( struct node)) );
}
nodeptr push(nodeptr parent)
{ nodeptr newnode = talloc();
newnode->node_id =
(parent->node_id) + 1;
newnode->prev = parent;
return newnode;
}
nodeptr pop( nodeptr t )
{
if(t != NULL)
{
nodeptr temp = t;
t = t->prev;
free( temp );
return t;
}
}
void display_stack(nodeptr temp)
{
printf("stack\n");
while(temp != NULL)
{ printf("%d\n", temp->node_id );
temp = temp->prev;
}
}
int APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow )
{
nodeptr top;
nodeptr root;
root = talloc();
root->node_id = 1;
root->prev = NULL;
top = root;
top = push(top);
top = push(top);
display_stack(top);
top = pop(top);
top = pop(top);
display_stack(top);
printf("\n");
top = pop(top); // free(root);
system ("pause");
return 0;
}