-
Notifications
You must be signed in to change notification settings - Fork 0
/
stacklib.h
34 lines (32 loc) · 956 Bytes
/
stacklib.h
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
29
30
31
32
33
34
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef STACK_LIB
#define STACK_LIB
#define MAX_STACK_SIZE 200
#define MAX_STRING_SIZE 150
typedef struct Stack Stack_t;
struct Stack {
char stack[MAX_STACK_SIZE][MAX_STRING_SIZE];
int top;
};
// top = -1 at initializaion.
// initializes the stack. This function must be called after the memory is created.
void initializeStack(Stack_t *stack);
// Check if the stack is empty.
bool isEmpty(Stack_t *stack);
// Check if the stack is full.
bool isFull(Stack_t *stack);
// Inspect the top most element of stack.
char *peek(Stack_t *stack);
// get the top most object out of the stack.
char *pop(Stack_t *stack);
// push the data into the stack.
void push(char *data, Stack_t *stack);
// inspect all the elements of the stack. (developing use)
void inspectStack(Stack_t *stack);
//reverses the stack
void reverse(Stack_t *stack);
#endif // STACK_LIB