diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34e908a --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.direnv +*.o +obj/ +compile_commands.json +.cache +*.d + +whatever +iter diff --git a/ex00/main.cpp b/ex00/main.cpp index adcf478..94ba6fe 100644 --- a/ex00/main.cpp +++ b/ex00/main.cpp @@ -6,7 +6,7 @@ /* 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 a = 2; - int b = 8; - - std::cout << "a: " << a << " and b: " << b << std::endl; - std::cout << "min betweeen a and b: " << min(a, b) << std::endl; - std::cout << "max betweeen a and b: " << max(a, b) << std::endl; - std::cout << "swapping a and b" << std::endl; - swap(a, b); - std::cout << "a: " << a << " and b: " << b << std::endl; - std::cout << "min betweeen a and b: " << min(a, b) << std::endl; - std::cout << "max betweeen a and b: " << max(a, b) << std::endl; - + int b = 3; + ::swap(a, b); + std::cout << "a = " << a << ", b = " << b << std::endl; + std::cout << "min( a, b ) = " << ::min(a, b) << std::endl; + std::cout << "max( a, b ) = " << ::max(a, b) << std::endl; + std::string c = "chaine1"; + std::string d = "chaine2"; + ::swap(c, d); + std::cout << "c = " << c << ", d = " << d << std::endl; + std::cout << "min( c, d ) = " << ::min(c, d) << std::endl; + std::cout << "max( c, d ) = " << ::max(c, d) << std::endl; + return 0; } diff --git a/ex00/obj/main.d b/ex00/obj/main.d deleted file mode 100644 index 2c5bb4b..0000000 --- a/ex00/obj/main.d +++ /dev/null @@ -1,3 +0,0 @@ -obj/./main.o: main.cpp whatever.hpp - -whatever.hpp: diff --git a/ex00/obj/main.o b/ex00/obj/main.o deleted file mode 100644 index b42db2f..0000000 Binary files a/ex00/obj/main.o and /dev/null differ diff --git a/ex00/whatever b/ex00/whatever deleted file mode 100755 index 1952895..0000000 Binary files a/ex00/whatever and /dev/null differ diff --git a/ex01/Makefile b/ex01/Makefile new file mode 100644 index 0000000..902f5c7 --- /dev/null +++ b/ex01/Makefile @@ -0,0 +1,60 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: adjoly +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# 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 diff --git a/ex01/iter.hpp b/ex01/iter.hpp new file mode 100644 index 0000000..23c24b6 --- /dev/null +++ b/ex01/iter.hpp @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* iter.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/04/09 14:56:23 by adjoly #+# #+# */ +/* Updated: 2025/04/09 15:21:01 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +template void iter(T *arr, int len, void(*func)(T &)) { + for (int i = 0; i< len; i++) { + func(arr[i]); + } +} diff --git a/ex01/main.cpp b/ex01/main.cpp new file mode 100644 index 0000000..ab47724 --- /dev/null +++ b/ex01/main.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/04/09 15:17:59 by adjoly #+# #+# */ +/* Updated: 2025/04/09 15:20:20 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "iter.hpp" +#include + +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; + } +}