Skip to content
Snippets Groups Projects

Add stack_print(stack) function

Merged boris.stefanov requested to merge 12-add-print-function into main
1 unresolved thread
1 file
+ 8
4
Compare changes
  • Side-by-side
  • Inline
+ 8
4
@@ -18,9 +18,13 @@ void stack_peek(stack s, int *value){
@@ -18,9 +18,13 @@ void stack_peek(stack s, int *value){
}
}
void stack_print(const stack s) {
void stack_print(const stack s) {
printf(" TOP\n--------------------\n");
if (s.top >= 0) {
for (int* spot = s.data + s.top; spot >= s.data; --spot) {
printf(" TOP\n--------------------\n");
printf("%8d | %12d\n", spot - s.data, *spot);
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");
}
}
printf("--------------------\n BOTTOM\n");
}
}
Loading