From 66f498164969913eb77867d8601594823b47ac24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Tue, 15 Oct 2024 10:21:37 +0200 Subject: [PATCH] ft_strlen: initial implementation also create libft.h --- Makefile | 5 +++-- ft_strlen.c | 23 +++++++++++++++++++++++ libft.h | 26 ++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 ft_strlen.c create mode 100644 libft.h diff --git a/Makefile b/Makefile index 6ddd6fa..131260e 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: kcolin +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/14 13:43:59 by kcolin #+# #+# # -# Updated: 2024/10/14 15:02:59 by kcolin ### ########.fr # +# Updated: 2024/10/14 15:11:56 by kcolin ### ########.fr # # # # **************************************************************************** # @@ -16,7 +16,8 @@ SOURCES = ft_isalpha.c \ ft_isdigit.c \ ft_isalnum.c \ ft_isascii.c \ - ft_isprint.c + ft_isprint.c \ + ft_strlen.c OBJECTS = $(SOURCES:.c=.o) CC = gcc diff --git a/ft_strlen.c b/ft_strlen.c new file mode 100644 index 0000000..313ae0f --- /dev/null +++ b/ft_strlen.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kcolin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/14 15:12:02 by kcolin #+# #+# */ +/* Updated: 2024/10/15 10:17:25 by kcolin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +t_size ft_strlen(const char *s) +{ + int i; + + i = 0; + while (s[i] != '\0') + i++; + return (i); +} diff --git a/libft.h b/libft.h new file mode 100644 index 0000000..9ced8ab --- /dev/null +++ b/libft.h @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kcolin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/15 10:11:54 by kcolin #+# #+# */ +/* Updated: 2024/10/15 10:18:46 by kcolin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_H +# define LIBFT_H + +typedef unsigned int t_size; + +int ft_isalpha(int c); +int ft_isdigit(int c); +int ft_isalnum(int c); +int ft_isascii(int c); +int ft_isprint(int c); + +t_size ft_strlen(const char *s); + +#endif