Examples and fixing stuff
This commit is contained in:
1 parent
a8c1619be6
commit
bd338f2fe3
10 files changed
+42
-47
No files matched your search
+15
-20
@@ -2,36 +2,31 @@ CC=gcc
|
||||
CFLAGS=-Wall -Wextra -Werror -O3
|
||||
INCLUDE=-I ../src
|
||||
|
||||
dfs: dfs.c
|
||||
$(CC) $< -o $@.exe $(CFLAGS) $(INCLUDE)
|
||||
./$@.exe
|
||||
|
||||
example: example.c
|
||||
$(CC) $< -o $@.exe $(CFLAGS) $(INCLUDE)
|
||||
./$@.exe
|
||||
|
||||
hanoi: hanoi.c
|
||||
$(CC) $< -o $@.exe $(CFLAGS) $(INCLUDE)
|
||||
./$@.exe
|
||||
|
||||
heapsort: heapsort.c
|
||||
$(CC) $< -o $@.exe $(CFLAGS) $(INCLUDE)
|
||||
./$@.exe
|
||||
|
||||
sieve: sieve.c
|
||||
ifndef FILE
|
||||
main:
|
||||
@echo Please define a FILE parameter to run. Examples:
|
||||
@echo " dfs"
|
||||
@echo " example"
|
||||
@echo " hanoi"
|
||||
@echo " heapsort"
|
||||
@echo " ice_cream"
|
||||
@echo " sieve"
|
||||
else
|
||||
$(FILE): $(FILE).c
|
||||
$(CC) $< -o $@.exe $(CFLAGS) $(INCLUDE)
|
||||
./$@.exe
|
||||
endif
|
||||
|
||||
|
||||
clean:
|
||||
rm *.exe
|
||||
rm *.txt
|
||||
rm *.exe -f
|
||||
rm *.txt -f
|
||||
|
||||
|
||||
memcheck:
|
||||
ifndef FILE
|
||||
$(error FILE parameter must be set first to check for leaks)
|
||||
else
|
||||
$(CC) $(FILE) -o mem.exe $(CFLAGS) $(INCLUDE) -g
|
||||
$(CC) $(FILE).c -o mem.exe $(CFLAGS) $(INCLUDE) -g
|
||||
valgrind --leak-check=yes ./mem.exe
|
||||
endif
|
||||
+1
-1
@@ -61,7 +61,7 @@ int main(void)
|
||||
|
||||
printf("Stack:\n");
|
||||
fprintf(stdout, "[ ");
|
||||
struct Stack *stack = stk_new(100, &(struct StackFVal){ NULL });
|
||||
struct Stack *stack = stk_new(100, &(struct StackFVal){ 0 });
|
||||
|
||||
struct BinaryTreeNode *node = tree->root;
|
||||
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@ struct
|
||||
struct stack *from;
|
||||
struct stack *aux;
|
||||
struct stack *to;
|
||||
} print_aux = { NULL };
|
||||
} print_aux = { 0 };
|
||||
|
||||
void print_stacks()
|
||||
{
|
||||
@@ -50,9 +50,9 @@ void hanoi(int n, struct stack *from, struct stack *aux, struct stack *to)
|
||||
|
||||
int main()
|
||||
{
|
||||
struct stack from = stk_init(10, &(struct stack_fval){ NULL });
|
||||
struct stack to = stk_init(10, &(struct stack_fval){ NULL });
|
||||
struct stack aux = stk_init(10, &(struct stack_fval){ NULL });
|
||||
struct stack from = stk_init(10, &(struct stack_fval){ 0 });
|
||||
struct stack to = stk_init(10, &(struct stack_fval){ 0 });
|
||||
struct stack aux = stk_init(10, &(struct stack_fval){ 0 });
|
||||
|
||||
for (int i = disks; i >= 1; i--)
|
||||
stk_push(&from, i);
|
||||
|
||||
Reference in new issue
Block a user