Skip to content
Snippets Groups Projects

Resolve "Add clear function"

Merged orestis.malaspin requested to merge 13-add-clear-function into main
All threads resolved!
Files
2
+ 13
5
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "stack.h"
#include "stack.h"
#include <stdio.h>
 
#include <stdlib.h>
#define DEFAULT_CAPACITY 4
#define DEFAULT_CAPACITY 4
@@ -87,4 +84,15 @@ int get_length(stack s) {
@@ -87,4 +84,15 @@ int get_length(stack s) {
bool stack_is_empty(stack s)
bool stack_is_empty(stack s)
{
{
return s.top == -1;
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
Loading