From 21e04cc22c91bb813be241ce923d3f2388114d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Wed, 16 Oct 2024 10:28:00 +0200 Subject: [PATCH] ft_toupper: initial implementation --- Makefile | 5 +++-- ft_toupper.c | 36 ++++++++++++++++++++++++++++++++++++ libft.h | 4 +++- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 ft_toupper.c diff --git a/Makefile b/Makefile index b1b2aaf..166c9ba 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: kcolin +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/14 13:43:59 by kcolin #+# #+# # -# Updated: 2024/10/15 16:00:12 by kcolin ### ########.fr # +# Updated: 2024/10/16 09:58:22 by kcolin ### ########.fr # # # # **************************************************************************** # @@ -23,7 +23,8 @@ SOURCES = ft_isalpha.c \ ft_memcpy.c \ ft_memmove.c \ ft_strlcpy.c \ - ft_strlcat.c + ft_strlcat.c \ + ft_toupper.c OBJECTS = $(SOURCES:.c=.o) CC = gcc diff --git a/ft_toupper.c b/ft_toupper.c new file mode 100644 index 0000000..6e4bdc9 --- /dev/null +++ b/ft_toupper.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_toupper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kcolin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/16 09:58:42 by kcolin #+# #+# */ +/* Updated: 2024/10/16 10:25:57 by kcolin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_toupper(int c) +{ + if (c >= 'a' && c <= 'z') + c -= 0x20; + return (c); +} + +/* +#include +#include + +int main(void) +{ + int i; + + i = 0; + while (i < 256) + { + printf("%d\t%c\t%c\t%c\n", i, i, ft_toupper(i), toupper(i)); + i++; + } + return (0); +} +*/ diff --git a/libft.h b/libft.h index 5d9298a..48ca73c 100644 --- a/libft.h +++ b/libft.h @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/15 10:11:54 by kcolin #+# #+# */ -/* Updated: 2024/10/15 15:59:51 by kcolin ### ########.fr */ +/* Updated: 2024/10/16 10:24:26 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,4 +30,6 @@ void *ft_memmove(void *dest, const void *src, t_size n); t_size ft_strlcpy(char *dst, const char *src, t_size size); t_size ft_strlcat(char *dst, const char *src, t_size size); +int ft_toupper(int c); + #endif