From 48e1ff994eff48b791541201217a3c73ca81947a Mon Sep 17 00:00:00 2001 From: Blake Romero Date: Thu, 19 Sep 2024 18:09:18 +0100 Subject: Move main.c to demo & update Makefile --- Makefile | 7 +++++++ demo/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ main.c | 42 ------------------------------------------ 3 files changed, 52 insertions(+), 42 deletions(-) create mode 100644 demo/main.c delete mode 100644 main.c diff --git a/Makefile b/Makefile index 42176f0..eea4ff8 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ test: $(test_bins) clean: rm -r $(bin_dir) $(obj_dir) +.PHONY: demo +demo: $(bin_dir)/demo + .PHONY: info info: @printf "src_files: %s\n" $(src_files) @@ -47,3 +50,7 @@ $(obj_dir)/%.o: $(src_dir)/%.c $(obj_dir) # Make test binaries $(bin_dir)/%: $(bin_dir) $(test_files) $(obj_files) $(CC) $(CFLAGS) -o $@ -l $(test_framework) $(filter-out $<,$^) + +# Make demo executable +$(bin_dir)/demo: $(bin_dir) $(obj_files) demo/main.c + $(CC) $(CFLAGS) -o $@ $(filter-out $<,$^) diff --git a/demo/main.c b/demo/main.c new file mode 100644 index 0000000..46fce13 --- /dev/null +++ b/demo/main.c @@ -0,0 +1,45 @@ +#include "../src/ll.h" + +int main() { + int val = 7; + Node* head = llnode(val); + /* printf("Init with %i:\t", val); */ + /* llprint(head); */ + + /* val = 12; */ + /* llpush(&head, val); */ + /* printf("Push %i:\t", val); */ + /* llprint(head); */ + + /* val = 99; */ + /* printf("Append %i:\t", val); */ + /* llappend(head,val); */ + /* llprint(head); */ + + /* val = 45; */ + /* printf("Insert %i:\t", val); */ + /* llinsert(&head, val, 2); */ + /* llprint(head); */ + + /* val = 42; */ + /* printf("Insert %i:\t", val); */ + /* llinsert(&head, val, 1); */ + /* llprint(head); */ + + /* printf("Pop %i:\t\t", llpop(&head)); */ + /* llprint(head); */ + + /* printf("Remove %i:\t",llrmlast(&head)); */ + /* llprint(head); */ + + /* printf("Remove %i:\t",llrm(&head,1)); */ + /* llprint(head); */ + + /* llvprint(head); */ + + head->next = llnode(14); + head->next->next = llnode(22); + llfree(&head); + llprint(head); + printf("Length: %i\n", lllength(head)); +} diff --git a/main.c b/main.c deleted file mode 100644 index 739a949..0000000 --- a/main.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "../src/ll.h" - -int main() { - int val = 7; - Node* head = llnode(val); - printf("Init with %i:\t", val); - llprint(head); - - val = 12; - llpush(&head, val); - printf("Push %i:\t", val); - llprint(head); - - val = 99; - printf("Append %i:\t", val); - llappend(head,val); - llprint(head); - - val = 45; - printf("Insert %i:\t", val); - llinsert(&head, val, 2); - llprint(head); - - val = 42; - printf("Insert %i:\t", val); - llinsert(&head, val, 1); - llprint(head); - - printf("Pop %i:\t\t", llpop(&head)); - llprint(head); - - printf("Remove %i:\t",llrmlast(&head)); - llprint(head); - - printf("Remove %i:\t",llrm(&head,1)); - llprint(head); - - llvprint(head); - - /* llfree(head); */ - printf("Length: %i\n",lllength(head)); -} -- cgit