Different implementations of a stack data structure in C, inspired by JavaScript.
git clone [email protected]:Luzefiru/c-stack-practice.git
cd c-stack-practice
make start # builds & runs the C implementation
make start-java # builds & runs the Java implementation
make clean # deletes .o & .class build artifacts
You'll need to run make start
in a Bash instance or use GNUWin to add the make
command to cmd.
- add makefile scripts and descriptions
We'll have to change the IMPLEMENTATION
variable inside Makefile
which points to the directory inside /src/stack/$(IMPLEMENTATION)/stack.c
.
# the variable to change
IMPLEMENTATION := cursor # can also be list or array
# the compiled stack object code
stack.o:
gcc -c ./src/stack/$(IMPLEMENTATION)/stack.c
File directory structure follows the pitchfork convention used in big C++ and C projects.
Makefile # build scripts
src/
├── main.c # driver program
└── stack/
├── array/
│ └── stack.c # array implementation
├── cursor/
│ └── stack.c # cursor-based list implementation
├── list/
│ └── stack.c # linked list implementation
│
└── java/ # Java implementation
├── Main.class # Java driver program
├── Stack.class # Stack class & method definitions
└── IStack.class # IStack interface imitating a header file
include/
└── stack.h # included header file with function prototypes & documentation