Add ex00 solution
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 3 Oct 2024 08:42:29 +0000 (10:42 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 3 Oct 2024 08:42:29 +0000 (10:42 +0200)
ex00/Makefile [new file with mode: 0644]
ex00/megaphone.cpp [new file with mode: 0644]

diff --git a/ex00/Makefile b/ex00/Makefile
new file mode 100644 (file)
index 0000000..c461687
--- /dev/null
@@ -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 (file)
index 0000000..4437728
--- /dev/null
@@ -0,0 +1,20 @@
+#include <iostream>
+#include <cstring>
+#include <cctype>
+
+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);
+}