blob: 0498abc5c4523a4bb7c354db57c84ee862c1f60b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "stack.h"
#include <stdlib.h>
struct stack *stack_push(struct stack *s, int e)
{
struct stack *new = malloc(sizeof(struct stack));
new->data = e;
new->next = NULL;
new->next = s;
return new;
}
struct stack *stack_pop(struct stack *s)
{
if (s == NULL)
{
return NULL;
}
struct stack *res = s->next;
free(s);
return res;
}
int stack_peek(struct stack *s)
{
return s->data;
}
|