From 914eb94ff6e16cf71c58e6aac5bcc07d75e6fd42 Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Mon, 4 Nov 2024 19:18:41 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E2=9C=A8=E3=80=8D=20feat(Hi=20this=20?= =?UTF-8?q?is=20a=20brain):=20Finished=20ex02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ ex02/Makefile | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ ex02/main.cpp | 30 ++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 ex02/Makefile create mode 100644 ex02/main.cpp diff --git a/.gitignore b/.gitignore index 90c63de..66599d1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ compile_commands.json flake.lock zombie zombieHorde +thisisabrain +violence diff --git a/ex02/Makefile b/ex02/Makefile new file mode 100644 index 0000000..624f674 --- /dev/null +++ b/ex02/Makefile @@ -0,0 +1,54 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: adjoly +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2024/10/25 16:09:27 by adjoly #+# #+# # +# Updated: 2024/11/04 19:17:46 by adjoly ### ########.fr # +# # +# **************************************************************************** # + +NAME = thisisabrain + +CC = c++ + +OBJSDIR = obj/ + +SRCS = main.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 + +all: $(NAME) + +$(NAME): $(OBJS) + @$(CC) $(FLAGS) $(OBJS) -o $(NAME) + @printf "$(YELLOW)「✨」($(NAME)) Program compiled\n" + +$(OBJSDIR)%.o: %.cpp + @mkdir -p $(@D) + @$(CC) $(FLAGS) -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/ex02/main.cpp b/ex02/main.cpp new file mode 100644 index 0000000..2c40a37 --- /dev/null +++ b/ex02/main.cpp @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:01:36 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:15:33 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int main(void) { + std::string str = "HI THIS IS BRAIN"; + std::string *stringPTR = &str; + std::string &stringREF = str; + + std::cout << "The address of the string : " << &str << std::endl; + std::cout << "The address of the string pointer : " << stringPTR << std::endl; + std::cout << "The address of the string reference : " << &stringREF << std::endl; + + std::cout << std::endl; + + std::cout << "The value of the string : " << str << std::endl; + std::cout << "The value pointed to by stringPTR : " << *stringPTR << std::endl; + std::cout << "The value pointed to by stringREF : " << stringREF << std::endl; +}