Skip to content
Snippets Groups Projects

add function stack_push

Merged richarda.tyarks requested to merge 5-add-push-function into main
Files
2
+ 7
1
#include "stack.h"
#include <stdio.h>
#include <stdlib.h>
@@ -17,6 +16,12 @@ void stack_destroy(stack *s) {
s->top = -1;
}
void stack_push(stack *s, int value)
{
s->top++;
s->data[s->top] = value;
}
void stack_pop(stack *s, int *value) {
if (stack_is_empty(*s)) {
return;
@@ -62,3 +67,4 @@ void stack_clone(stack s, stack *clone) {
int get_length(stack s) {
return s.top + 1;
}
Loading