Skip to content
Snippets Groups Projects
Commit 93cf8510 authored by alec.schmidt's avatar alec.schmidt Committed by orestis.malaspin
Browse files

* Added `stack_init()` function

* Added `DEFAULT_CAPACITY` constant 
parent 1ccc0ef1
Branches
Tags
1 merge request!8Added init function
#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
......@@ -7,4 +7,6 @@ typedef struct _stack {
int top;
} stack;
void stack_init(stack *stack);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment