「🎉」 init: hello world !
This commit is contained in:
58
ex01/Makefile
Normal file
58
ex01/Makefile
Normal 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:04:00 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 = ex01
|
||||
|
||||
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
|
||||
13
ex01/iter.hpp
Normal file
13
ex01/iter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
template<typename T> void iter(T *arr, int len, void(*func)(T &)) {
|
||||
for (int i = 0; i< len; i++) {
|
||||
func(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> void iter(const T *arr, int len, void(*func)(const T &)) {
|
||||
for (int i = 0; i< len; i++) {
|
||||
func(arr[i]);
|
||||
}
|
||||
}
|
||||
23
ex01/main.cpp
Normal file
23
ex01/main.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "iter.hpp"
|
||||
#include <iostream>
|
||||
|
||||
void increment(int &nb)
|
||||
{
|
||||
nb++;
|
||||
}
|
||||
|
||||
void print(const int &nb)
|
||||
{
|
||||
std::cout << nb << " ";
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int arr[4] = {1, 2, 3, 4};
|
||||
|
||||
iter(arr, 4, &print);
|
||||
std::cout << std::endl;
|
||||
iter(arr, 4, &increment);
|
||||
iter(arr, 4, &print);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user