-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
28 lines (25 loc) · 727 Bytes
/
Copy pathstack.h
File metadata and controls
28 lines (25 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef STACK_H
#define STACK_H
#include<stdio.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdlib.h>
typedef struct {
void** array; // Array to store elements
int top; // Index of top element
int size; // Current size of stack
int capacity; // Maximum number of elements
size_t elementSize; // Size of each element
} Stack;
Stack* createStack(size_t elementSize, int capacity);
void freeStack(Stack* stack);
void push(Stack* stack, void* element);
void* pop(Stack* stack);
bool isEmpty(Stack* stack);
bool isFull(Stack* stack);
void* peek(Stack* stack);
void printElement(void* element, void(*printFunc) (void*));
void printInt(void* element);
void printFloat(void* element);
void printChar(void* element);
#endif