Skip to content
Snippets Groups Projects
Commit f10345b1 authored by jonas.stirnema's avatar jonas.stirnema
Browse files

Added stack_clear function

parent f39dc138
No related branches found
No related tags found
1 merge request!20Resolve "Add clear function"
This commit is part of merge request !20. Comments created here will be created in the context of that merge request.
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "stack.h"
......@@ -87,4 +83,15 @@ int get_length(stack s) {
bool stack_is_empty(stack s)
{
return s.top == -1;
}
/**
* @brief Reset the stack's top to -1
* New values will overwrite the old ones
*
* @param s
*/
void stack_clear(stack *s)
{
s->top = -1;
}
\ No newline at end of file
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#ifndef _STACK_H_
#define _STACK_H_
......@@ -17,6 +21,7 @@ void stack_peek(stack s, int *value);
void stack_clone(stack s, stack *clone);
int get_length(stack s);
bool stack_is_empty(stack s);
void stack_clear(stack *s) ;
void stack_print(const stack s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment