1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00
programming-challenges/challenges/reverse-polish-notation/solutions/c/function/stack.h

55 lines
772 B
C

#ifndef __STACK__
#define __STACK__
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
/**
* @brief Stack structure => LIFO (Last In First Out).
*/
struct stack {
struct stack_node *first;
size_t length;
};
/**
* @brief Stack node structure.
*/
struct stack_node {
void *data;
struct stack_node *next;
};
/**
* @brief Stack initialization.
*
* @return struct stack*
*/
struct stack *stack_initialization();
/**
* @brief Push data to stack.
*
* @param stack
* @param data
*/
void stack_push(struct stack *stack, void *data);
/**
* @brief Pop data from stack.
*
* @param stack
* @return void*
*/
void *stack_pop(struct stack *stack);
/**
* @brief Frees the stack.
*
* @param stack
*/
void stack_free(struct stack *stack);
#endif