Skip to content
Snippets Groups Projects
Commit 9d7603c5 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

Merge branch 'main' into '8-add-get-length-function'

# Conflicts:
#   stack.c
parents e2b5ab74 1dec4649
Branches
No related tags found
1 merge request!15"Add get length function"
......@@ -17,6 +17,20 @@ void stack_peek(stack s, int *value){
}
}
void stack_print(const stack s) {
//TODO: replace if statement with following as soon as relevant function is implemented
//if (!stack_is_empty()) {
if (s.top >= 0) {
printf(" TOP\n--------------------\n");
for (int* spot = s.data + s.top; spot >= s.data; --spot) {
printf("%8d | %12d\n", spot - s.data, *spot);
}
printf("--------------------\n BOTTOM\n");
} else {
printf("STACK EMPTY\n");
}
}
void stack_clone(stack s, stack *clone) {
clone->top = s.top;
clone->capacity = s.capacity;
......@@ -30,3 +44,4 @@ int get_length(stack s)
{
return s->top + 1;
}
......@@ -13,4 +13,6 @@ void stack_peek(stack s, int *value);
void stack_clone(stack s, stack *clone);
int get_length(stack s);
void stack_print(const stack s);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment