From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- rushs/tinyprintf/stack/stack.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 rushs/tinyprintf/stack/stack.c (limited to 'rushs/tinyprintf/stack/stack.c') diff --git a/rushs/tinyprintf/stack/stack.c b/rushs/tinyprintf/stack/stack.c new file mode 100644 index 0000000..0498abc --- /dev/null +++ b/rushs/tinyprintf/stack/stack.c @@ -0,0 +1,30 @@ +#include "stack.h" + +#include + +struct stack *stack_push(struct stack *s, int e) +{ + struct stack *new = malloc(sizeof(struct stack)); + new->data = e; + new->next = NULL; + + new->next = s; + return new; +} + +struct stack *stack_pop(struct stack *s) +{ + if (s == NULL) + { + return NULL; + } + + struct stack *res = s->next; + free(s); + return res; +} + +int stack_peek(struct stack *s) +{ + return s->data; +} -- cgit v1.2.3