Created
August 16, 2019 18:45
-
-
Save devansh42/b14ba561f675581e9aace0ff41ff0919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stack.h" | |
#include<stdlib.h> | |
BasicStack* new_basic_stack(int cap){ | |
BasicStack* s; | |
//Allocating memory for Basic Stack Structure | |
s=(BasicStack*)malloc(sizeof(BasicStack)); | |
//Allocating memory for Array used to hold stack | |
s->ar=malloc(sizeof(int)*cap); | |
//Setting capcity of stack | |
s->cap=cap; | |
//Setting intial size of stack | |
s->size=0; | |
return s; | |
} | |
void delete_basic_stack(BasicStack* s){ | |
//Freeing memory associated with array containing stack | |
free(s->ar); | |
//Freeing memory associated with BasicStack struct | |
free(s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment