You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
715 B
43 lines
715 B
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct LinkStack
|
|
{
|
|
char data;
|
|
struct LinkStack *next;
|
|
} LinkStack;
|
|
|
|
LinkStack *push(LinkStack *top, char a)
|
|
{
|
|
LinkStack *line = (LinkStack *)malloc(sizeof(LinkStack));
|
|
line->data = a;
|
|
line->next = top;
|
|
top = line;
|
|
return top;
|
|
}
|
|
|
|
LinkStack *pop(LinkStack *top)
|
|
{
|
|
if (top)
|
|
{
|
|
LinkStack *p = top;
|
|
top = top->next;
|
|
printf("current = %c \n", p->data);
|
|
if (top)
|
|
{
|
|
printf("top = %c\n", top->data);
|
|
}
|
|
else
|
|
{
|
|
printf("empty\n");
|
|
}
|
|
free(p);
|
|
}
|
|
else
|
|
{
|
|
printf("Stack Empty\n");
|
|
return top;
|
|
}
|
|
return top;
|
|
}
|