Compare commits
10 commits
37cfb490dc
...
d36e5ddf1d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d36e5ddf1d | ||
|
|
4fb3dac7f3 | ||
|
|
de9fd295d8 | ||
|
|
d1dc958714 | ||
|
|
e0880b7172 | ||
|
|
1802311034 | ||
|
|
93dcdf9491 | ||
|
|
98639235c0 | ||
|
|
c960cd6f32 | ||
|
|
9d46cee039 |
4 changed files with 50 additions and 13 deletions
16
.gitignore
vendored
16
.gitignore
vendored
|
|
@ -4,22 +4,18 @@ build/
|
|||
*.d
|
||||
*.dSYM/
|
||||
|
||||
/Colleen/Colleen
|
||||
/Grace/Grace
|
||||
/Sully/Sully
|
||||
*/Colleen/Colleen
|
||||
*/Grace/Grace
|
||||
*/Sully/Sully
|
||||
|
||||
Colleen_kid.c
|
||||
Grace_kid.c
|
||||
Sully_*.c
|
||||
Colleen_kid.*
|
||||
Grace_kid.c*
|
||||
Sully_*.c*
|
||||
Sully_*
|
||||
|
||||
*.swp
|
||||
*~
|
||||
.DS_Store
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
# Clang tools
|
||||
.clangd
|
||||
.clang-format
|
||||
compile_commands.json
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ const char *get_program(void) {
|
|||
}
|
||||
|
||||
int main(void) {
|
||||
printf(get_program(), '\n', '\t', '"', get_program());
|
||||
printf(get_program(), 10, 9, 34, get_program());
|
||||
}
|
||||
|
|
|
|||
14
C/Grace/Grace.c
Normal file
14
C/Grace/Grace.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TO_WRITE "#include <stdio.h>%1$c#include <stdlib.h>%1$c%1$c#define TO_WRITE %3$c%4$s%3$c%1$c#define NULL_CHECK(ptr){if (ptr == NULL) exit(1);}%1$c#define PROG()int main(void) {%2$cFILE *new_file = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c);%2$cNULL_CHECK(new_file);%2$cfprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE);%2$cfclose(new_file);%2$creturn 0;}%1$c%1$c/**%1$c * @brief Actually the only is to hide this main on a define%1$c *%1$c * @return 0 on success overwise return 1%1$c */%1$c%1$cPROG()%1$c"
|
||||
#define NULL_CHECK(ptr){if (ptr == NULL) exit(1);}
|
||||
#define PROG()int main(void) { FILE *new_file = fopen("Grace_kid.c", "w"); NULL_CHECK(new_file); fprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE); fclose(new_file); return 0;}
|
||||
|
||||
/**
|
||||
* @brief Actually the only is to hide this main on a define
|
||||
*
|
||||
* @return 0 on success overwise return 1
|
||||
*/
|
||||
|
||||
PROG()
|
||||
31
C/Makefile
31
C/Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2026/01/30 16:34:30 by rparodi ### ########.fr #
|
||||
# Updated: 2026/01/30 23:25:20 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -54,6 +54,8 @@ all: header $(NAME) footer
|
|||
|
||||
# Exercices
|
||||
ex0: $(COLLEEN)
|
||||
ex1: $(GRACE)
|
||||
ex2: $(SULLY)
|
||||
|
||||
# Dependences for all
|
||||
$(NAME): $(COLLEEN) $(GRACE) $(SULLY)
|
||||
|
|
@ -91,6 +93,31 @@ $(OBJDIRNAME)/%.o: %.c
|
|||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||
@$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test: test_colleen test_grace test_sully
|
||||
|
||||
test_colleen: $(COLLEEN)
|
||||
@clear
|
||||
@rm -rf /tmp/test_colleen.c
|
||||
@$(COLLEEN) > /tmp/test_colleen.c
|
||||
@printf '$(GREY)Output of the $(GOLD)Colleen$(END)\n'
|
||||
@bat -plc /tmp/test_colleen.c
|
||||
@printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_COLLEEN) $(GREY)and $(GOLD)/tmp/test_colleen.c$(END)\n"
|
||||
@diff $(SRC_COLLEEN) /tmp/test_colleen.c | bat -ldiff
|
||||
|
||||
test_grace: $(GRACE)
|
||||
@$(GRACE)
|
||||
@printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(END)\n'
|
||||
@bat -plc ./Grace_kid.c
|
||||
@printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)Grace_kid.c $(END)\n"
|
||||
@diff $(SRC_GRACE) ./Grace_kid.c | bat -ldiff
|
||||
|
||||
test_sully: $(SULLY)
|
||||
@$(SULLY) > /tmp/test_sully.c
|
||||
@printf '$(GREY)Output of the $(GOLD)Sully$(END)\n'
|
||||
@bat -plc /tmp/test_sully.c
|
||||
@printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_SULLY) $(GREY)and $(GOLD)/tmp/test_sully.c$(END)\n"
|
||||
@diff $(SRC_SULLY) /tmp/test_sully | bat -ldiff
|
||||
|
||||
# Header
|
||||
header:
|
||||
@printf '\n\n'
|
||||
|
|
@ -104,7 +131,7 @@ header:
|
|||
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
||||
@printf '$(GOLD) ****** $(END)\n'
|
||||
@printf '$(GOLD) ****** $(END)\n'
|
||||
@printf '$(GREY) Made by glaruell & rparodi$(END)\n\n'
|
||||
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
||||
|
||||
# Footer
|
||||
footer:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue