From 2237e39a68e67c7559b2d54e4285a0b18d0421b3 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 3 Oct 2024 10:42:29 +0200 Subject: [PATCH 1/1] Add ex00 solution --- ex00/Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++ ex00/megaphone.cpp | 20 ++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 ex00/Makefile create mode 100644 ex00/megaphone.cpp diff --git a/ex00/Makefile b/ex00/Makefile new file mode 100644 index 0000000..c461687 --- /dev/null +++ b/ex00/Makefile @@ -0,0 +1,52 @@ +CC := c++ +CFLAGS = -std=c++98 -Wall -Wextra -Werror -Wpedantic + +ifneq ("$(wildcard .debug)","") + CFLAGS += -g +endif + +RM := rm -f + +INCDIR := inc +INCDIR += $(addsuffix /inc, $(SUBPROJECTS)); +ifneq ($(INCLUDE),) + INCLUDE := $(addprefix -I, $(INCDIR)) +endif + +SRCDIR := . + +SOURCES := megaphone.cpp + +SOURCES := $(addprefix $(SRCDIR)/, $(SOURCES)) + +OBJECTS := $(SOURCES:.cpp=.o) + +NAME := megaphone + +all : $(NAME) + +debug : .debug + $(MAKE) all + +nodebug : + $(RM) .debug + $(MAKE) re + +.% : + $(MAKE) shallow_fclean + touch $@ + +$(NAME) : $(OBJECTS) + $(CC) $(CFLAGS) -o $@ $^ $(LINKS) + +%.o : %.cpp + $(CC) $(CFLAGS) -o $@ -c $< $(INCLUDE) + +clean : + $(RM) $(OBJECTS) + +fclean : clean + $(RM) $(NAME) + +re : fclean + $(MAKE) all diff --git a/ex00/megaphone.cpp b/ex00/megaphone.cpp new file mode 100644 index 0000000..4437728 --- /dev/null +++ b/ex00/megaphone.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +char *make_uppercase(char *&str) +{ + for (size_t i = 0; i < std::strlen(str); ++i) + str[i] = std::toupper(str[i]); + return (str); +} + +int main(int argc, char **argv) +{ + if (argc == 1) + std::cout << "* LOUD AND UNBEARABLE FEEDBACK NOISE *"; + for (int i = 1; i < argc; ++i) + std::cout << make_uppercase(argv[i]); + std::cout << std::endl; + return (0); +} -- 2.30.2