1
0

🗑️」 clean: cleaned project.

This commit is contained in:
2025-04-09 15:21:27 +02:00
parent 9035e8da97
commit a432c8defd
8 changed files with 127 additions and 15 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.direnv
*.o
obj/
compile_commands.json
.cache
*.d
whatever
iter

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 14:29:59 by adjoly #+# #+# */ /* Created: 2025/04/09 14:29:59 by adjoly #+# #+# */
/* Updated: 2025/04/09 14:51:07 by adjoly ### ########.fr */ /* Updated: 2025/04/09 14:55:59 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,15 +15,16 @@
int main(void) { int main(void) {
int a = 2; int a = 2;
int b = 8; int b = 3;
::swap(a, b);
std::cout << "a: " << a << " and b: " << b << std::endl; std::cout << "a = " << a << ", b = " << b << std::endl;
std::cout << "min betweeen a and b: " << min(a, b) << std::endl; std::cout << "min( a, b ) = " << ::min(a, b) << std::endl;
std::cout << "max betweeen a and b: " << max(a, b) << std::endl; std::cout << "max( a, b ) = " << ::max(a, b) << std::endl;
std::cout << "swapping a and b" << std::endl; std::string c = "chaine1";
swap(a, b); std::string d = "chaine2";
std::cout << "a: " << a << " and b: " << b << std::endl; ::swap(c, d);
std::cout << "min betweeen a and b: " << min(a, b) << std::endl; std::cout << "c = " << c << ", d = " << d << std::endl;
std::cout << "max betweeen a and b: " << max(a, b) << std::endl; std::cout << "min( c, d ) = " << ::min(c, d) << std::endl;
std::cout << "max( c, d ) = " << ::max(c, d) << std::endl;
return 0;
} }

View File

@ -1,3 +0,0 @@
obj/./main.o: main.cpp whatever.hpp
whatever.hpp:

Binary file not shown.

Binary file not shown.

60
ex01/Makefile Normal file
View File

@ -0,0 +1,60 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/10/25 16:09:27 by adjoly #+# #+# #
# Updated: 2025/04/09 14:50:44 by adjoly ### ########.fr #
# #
# **************************************************************************** #
SHELL = bash
NAME = whatever
CC = c++
OBJSDIR = obj/
SRCS = $(shell find . -name '*.cpp')
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.cpp=.o))
FLAGS = -Wall -Werror -Wextra -std=c++98 -MMD -MP
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[1;33m
PURPLE = \e[0;35m
NC = \033[0m
DELETE = \x1B[2K\r
ifeq ($(VERBOSE),true)
FLAGS += -D VERBOSE
endif
all: $(NAME)
$(NAME): $(OBJS)
@$(CC) $(FLAGS) -I . $(OBJS) -o $(NAME)
@printf "$(YELLOW)「✨」($(NAME)) Program compiled\n"
$(OBJSDIR)%.o: %.cpp
@mkdir -p $(@D)
@$(CC) $(FLAGS) -I . -c $< -o $@
@printf "$(DELETE)$(GREEN)「🔨」($<) Object compiled\n"
clean:
@rm -f $(OBJS)
@printf "$(DELETE)$(RED)「🗑️」($(OBJS)) Object deleted\n"
fclean: clean
@rm -f $(NAME)
@rm -Rf $(OBJSDIR)
@printf "$(RED)「🗑️」($(NAME)) Program deleted\n"
re: fclean all
.PHONY: clean fclean all re

19
ex01/iter.hpp Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* iter.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 14:56:23 by adjoly #+# #+# */
/* Updated: 2025/04/09 15:21:01 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
template<typename T> void iter(T *arr, int len, void(*func)(T &)) {
for (int i = 0; i< len; i++) {
func(arr[i]);
}
}

26
ex01/main.cpp Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 15:17:59 by adjoly #+# #+# */
/* Updated: 2025/04/09 15:20:20 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "iter.hpp"
#include <iostream>
void test(int &nb) {
nb++;
}
int main(void) {
int test[4] = {1, 2, 3, 4};
for (int i = 0; i < 4; i++) {
std::cout << test[i] << std::endl;
}
}