diff --git a/stack.c b/stack.c index 7380615365c9ff15134d68009437f6d936444813..1813ff5cc17b36696b9dfd7428b8bf61d280b32e 100644 --- a/stack.c +++ b/stack.c @@ -1 +1,13 @@ #include "stack.h" +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +#define DEFAULT_CAPACITY 4 + +void stack_init(stack *s) +{ + s->top = -1; + s->capacity = DEFAULT_CAPACITY; + s->data = malloc(sizeof(int) * DEFAULT_CAPACITY); +} \ No newline at end of file diff --git a/stack.h b/stack.h index 9796be5f47ab539a622deaa3bf8b563157b7c7ab..dfdc9a1d8afe4525ad0ae59af873be50a78d2998 100644 --- a/stack.h +++ b/stack.h @@ -7,4 +7,6 @@ typedef struct _stack { int top; } stack; +void stack_init(stack *stack); + #endif