Skip to content
Snippets Groups Projects

Added init function

Merged alec.schmidt requested to merge stack_init into main
1 unresolved thread
Files
2
stack.c 0 → 100644
+ 14
0
 
#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");
Please register or sign in to reply
 
s->top = -1;
 
s->capacity = DEFAULT_CAPACITY;
 
s->data = malloc(sizeof(int) * DEFAULT_CAPACITY);
 
}
 
\ No newline at end of file
Loading