Skip to content
Snippets Groups Projects

"Add get length function"

Merged gaetan.siffert requested to merge 8-add-get-length-function into main
3 unresolved threads
2 files
+ 17
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 15
0
@@ -17,6 +17,20 @@ void stack_peek(stack s, int *value){
@@ -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) {
void stack_clone(stack s, stack *clone) {
clone->top = s.top;
clone->top = s.top;
clone->capacity = s.capacity;
clone->capacity = s.capacity;
@@ -30,3 +44,4 @@ int get_length(stack s)
@@ -30,3 +44,4 @@ int get_length(stack s)
{
{
return s->top + 1;
return s->top + 1;
}
}
 
Loading