From c5315913b382abb9783626186d3e44537ac9da90 Mon Sep 17 00:00:00 2001 From: "dario.genga" <dario.genga@etu.hesge.ch> Date: Tue, 23 Nov 2021 13:55:52 +0100 Subject: [PATCH] Add stack's methods signature Also fixed some typos in comments or define. --- README.md | 2 +- main.c | 4 ++-- stack.c | 2 +- stack.h | 18 +++++++++++++++--- test.c | 4 ++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0a99331..0e24627 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,6 @@ Use this command to compile the project. Use this command to clean the project. ### Run the tests -> `make run_tests` +> `make test` Use this command to start the tests. \ No newline at end of file diff --git a/main.c b/main.c index 736e7ff..5d111c2 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,6 @@ /* Author : Dario GENGA - * Date : 16.11.2021 - * Description : Library to manipulate the pile + * Date : 23.11.2021 + * Description : Library to manipulate the stack */ #include <stdio.h> diff --git a/stack.c b/stack.c index 4f024e2..b5030a9 100644 --- a/stack.c +++ b/stack.c @@ -1,5 +1,5 @@ /* Author : Dario GENGA - * Date : 16.11.2021 + * Date : 23.11.2021 * Description : Library to manipulate the stack */ diff --git a/stack.h b/stack.h index 207ee6e..d932928 100644 --- a/stack.h +++ b/stack.h @@ -1,12 +1,24 @@ /* Author : Dario GENGA - * Date : 16.11.2021 + * Date : 23.11.2021 * Description : Library to manipulate the stack */ -#ifndef _PILE_H -#define _PILE_H +#ifndef _STACK_H +#define _STACK_H #include <stdio.h> #include <stdlib.h> #include <stdbool.h> +typedef struct _stack { + int size; + int top; + int *data; +} stack; + +void stack_init(stack *s, int size); +bool stack_is_empty(stack s); +void stack_push(stack *s, int val); +void stack_pop(stack *s, int *val); +void stack_peek(stack s, int *val); +void stack_destroy(stack *s); #endif \ No newline at end of file diff --git a/test.c b/test.c index 1648701..79981eb 100644 --- a/test.c +++ b/test.c @@ -1,6 +1,6 @@ /* Author : Dario GENGA - * Date : 16.11.2021 - * Description : Manipulate matrix + * Date : 23.11.2021 + * Description : Library to manipulate the stack */ #include "stack.h" #include <assert.h> -- GitLab