🎉」 init: hello world !

This commit is contained in:
2025-08-16 20:30:27 +02:00
commit e0535f2b4a
9 changed files with 375 additions and 0 deletions

58
ex00/Makefile Normal file
View File

@@ -0,0 +1,58 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/01/22 07:21:18 by mmoussou #+# #+# #
# Updated: 2025/08/16 16:00:39 by mmoussou ### ########.fr #
# #
# **************************************************************************** #
SHELL = bash
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[1;33m
PURPLE = \e[0;35m
NC = \033[0m
DELETE = \x1B[2K
CC = c++
FLAGS = -std=c++98 -Wall -Werror -Wextra
INCLUDES = .
NAME = ex00
SRCS = main.cpp
OBJSDIR = obj/
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.cpp=.o))
all: $(NAME)
$(NAME): $(OBJS)
@$(CC) $(FLAGS) -I$(INCLUDES) $(OBJS) -o $(NAME)
@printf "$(NC)$(YELLOW)「✨」 feat($(NAME)): program compiled\n$(NC)"
$(OBJSDIR)%.o: %.cpp
@mkdir -p $(@D)
@$(CC) $(FLAGS) -I$(INCLUDES) -c $< -o $@
@printf "$(NC)$(GREEN)「🔨」 build($<): object compiled\n$(NC)"
clean:
@rm -f $(OBJS)
@printf "$(NC)$(RED)「🗑️」 clean($(OBJS)): object deleted\n$(NC)"
fclean: clean
@rm -f $(NAME)
@rm -Rf $(OBJSDIR)
@printf "$(NC)$(RED)「🗑️」 fclean($(NAME)): program deleted\n$(NC)"
re: fclean
@$(MAKE) -s all
.PHONY: clean fclean all re

23
ex00/main.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "whatever.hpp"
#include <iostream>
int main(void) {
int a = 2;
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;
}

21
ex00/whatever.hpp Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
template <typename T> void swap(T &a, T &b)
{
T tmp;
tmp = a;
a = b;
b = tmp;
}
template <typename T> T min(T &a, T &b)
{
return (a < b ? a : b);
}
template <typename T> T max(T &a, T&b)
{
return (a > b ? a : b);
}