├── Makefile ├── README.md ├── funct.c ├── funct.h ├── funct.o ├── main.c ├── main.o └── sneakers /Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -Wall -Wextra -std=c99 3 | SRC = main.c funct.c 4 | OBJ = $(SRC:.c=.o) 5 | EXEC = sneakers 6 | 7 | $(EXEC): $(OBJ) 8 | $(CC) $(CFLAGS) $(OBJ) -o $(EXEC) 9 | 10 | main.o: main.c funct.h # Added function.h as a dependency 11 | $(CC) $(CFLAGS) -c main.c 12 | 13 | funct.o: funct.c funct.h 14 | $(CC) $(CFLAGS) -c funct.c 15 | 16 | clean: 17 | rm -f $(OBJ) $(EXEC) 18 | 19 | #Edited By StephenLegacy 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Makefile Mastery 🛠️ 2 | 3 | Welcome to the **Makefile Mastery** repository! This is your go-to guide for understanding and using Makefiles effectively to automate tasks like compiling code, running tests, cleaning build files, and more. 4 | 5 | --- 6 | 7 | ## 🚀 Features 8 | - **Learn the Basics**: Understand what a Makefile is and why it’s useful. 9 | - **Step-by-Step Examples**: Dive into simple and advanced use cases. 10 | - **Best Practices**: Write optimized and readable Makefiles. 11 | - **Cross-Platform**: Use Makefiles for projects across Windows, macOS, and Linux. 12 | 13 | --- 14 | 15 | ## 📂 Repository Structure 16 | 17 | 18 | --- 19 | 20 | 21 | 22 | ## 🌟 What is a Makefile? 23 | A **Makefile** is a special file used by the `make` build automation tool. It defines a set of rules to execute tasks, such as compiling source code or managing dependencies. It’s especially useful in multi-file projects. 24 | 25 | ### Example: 26 | ```make 27 | all: hello 28 | 29 | hello: hello.o 30 | gcc -o hello hello.o 31 | 32 | hello.o: hello.c 33 | gcc -c hello.c 34 | 35 | clean: 36 | rm -f *.o hello 37 | .PHONY: animate 38 | 39 | animate: 40 | @echo "Starting animation..." 41 | @for i in {1..10}; do \ 42 | echo "Frame $$i"; \ 43 | echo "🚀 Moving forward..."; \ 44 | sleep 0.2; \ 45 | done 46 | @echo "Animation Complete!" 47 | run make 48 | 49 | 50 | -------------------------------------------------------------------------------- /funct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "funct.h" 3 | 4 | //Adding data to the arrays 5 | void populateSneakers(struct Sneakers *sneakersArray, int arraySize) { 6 | for (int i = 0; i < arraySize; i++) { 7 | printf("Enter details for Sneaker %d:\n", i + 1); 8 | printf("Name: "); 9 | scanf("%s", sneakersArray[i].name); 10 | printf("Size: "); 11 | scanf("%d", &sneakersArray[i].size); 12 | printf("Price: "); 13 | scanf("%f", &sneakersArray[i].price); 14 | printf("Stock: "); 15 | scanf("%d", &sneakersArray[i].stock); 16 | printf("\n\t_________________________________"); 17 | printf("\n"); 18 | } 19 | } 20 | 21 | // printing data saved in the arrays 22 | void printSneakers(struct Sneakers *sneakersArray, int arraySize) { 23 | printf("\n\tONESHOP SNEAKER CATALOGUE:\n"); 24 | printf("\n "); 25 | for (int i = 0; i < arraySize; i++) { 26 | printf("\t\tSneaker:%d:\n", i + 1); 27 | printf("\t\tName: %s\n", sneakersArray[i].name); 28 | printf("\t\tSize: %d\n", sneakersArray[i].size); 29 | printf("\t\tPrice: %.2f\n", sneakersArray[i].price); 30 | printf("\t\tStock: %d\n", sneakersArray[i].stock); 31 | printf("\n\t_________________________________"); 32 | printf("\n"); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /funct.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCT_H 2 | #define FUNCT_H 3 | 4 | struct Sneakers { 5 | char name[50]; 6 | int size; 7 | float price; 8 | int stock; 9 | }; 10 | 11 | void populateSneakers(struct Sneakers *sneakersArray, int arraySize); 12 | void printSneakers(struct Sneakers *sneakersArray, int arraySize); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /funct.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenLegacy/StructuresInC/40595f08a458e22d0aa11995fe001eaa55062cee/funct.o -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "funct.h" 3 | 4 | int main() { 5 | int arraySize; //The User Will provide a size each run time 6 | 7 | printf("\t WELCOME TO ONESHOP ENTERPRISES SNEAKER COLLECTION\n"); 8 | printf("\t*******************++++++***********************\n"); 9 | printf("\t To Proceed, Enter the number of sneakers to work with today: "); 10 | scanf("%d", &arraySize); 11 | struct Sneakers sneakersArray[arraySize]; 12 | printf("\n\t-----------------------------------\n"); 13 | populateSneakers(sneakersArray, arraySize); 14 | printf("\t "); 15 | printf("\n\t-----------------------------------\n"); 16 | 17 | printSneakers(sneakersArray, arraySize); 18 | printf("\n "); 19 | printf("\t-----------------------------------\n"); 20 | 21 | printf("\t STEPHEN OLOO\n"); 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenLegacy/StructuresInC/40595f08a458e22d0aa11995fe001eaa55062cee/main.o -------------------------------------------------------------------------------- /sneakers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenLegacy/StructuresInC/40595f08a458e22d0aa11995fe001eaa55062cee/sneakers --------------------------------------------------------------------------------