Skip to content
Snippets Groups Projects
Commit 2fc06c51 authored by Alec's avatar Alec
Browse files

Added init function

parent 6e8cc6fa
No related branches found
No related tags found
1 merge request!8Added init function
This commit is part of merge request !8. Comments created here will be created in the context of that merge request.
stack.c 0 → 100644
#include "stack.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define DEFAULT_CAPACITY 4
void stack_init(stack *s)
{
assert(s->data!=NULL && "Error : stack already in memory");
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