Skip to content
Snippets Groups Projects
Commit a27837de authored by Boris Stefanovic's avatar Boris Stefanovic
Browse files

ADD: stack_print(stack) function

parent 94a4d62f
No related branches found
No related tags found
1 merge request!12Add stack_print(stack) function
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
......@@ -16,3 +16,11 @@ void stack_peek(stack s, int *value){
*value = s.data[s.top];
}
}
void stack_print(const stack s) {
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");
}
......@@ -11,4 +11,6 @@ void stack_init(stack *stack);
void stack_peek(stack s, int *value);
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