Skip to content
Snippets Groups Projects

Resolve "Add pop function"

Merged ines.maya requested to merge 6-add-pop-function into main
2 unresolved threads
2 files
+ 7
3
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 6
3
// depile
void stack_pop(stack *s, int *value){
assert(s->top>=0 && "Stcak is empty\n");
if (stack_is_empty(*s)){
printf("stack is empty\n");
return;
}
if (s->top == s->capacity/4){
s->capacity /= 2;
s->data = realloc(s->data, sizeof(int)*s->capacity);
}
*value = s->data[s->top];
s->top -= 1;
}
\ No newline at end of file
Loading