From bdf52892a0e626bcb69498f1440c21b9207851f5 Mon Sep 17 00:00:00 2001 From: Aleksei Chubukov Date: Sat, 2 Dec 2023 23:46:24 +0400 Subject: [PATCH] create empty digits_to_words src, implement ft_strlen --- ex00/digits_to_words.c | 12 ++++++++++++ ex00/digits_to_words.h | 14 ++++++++++++++ ex00/ft_utils.c | 12 +++++++++++- ex00/main.c | 4 ++-- ex00/main.h | 5 +++-- 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 ex00/digits_to_words.c create mode 100644 ex00/digits_to_words.h diff --git a/ex00/digits_to_words.c b/ex00/digits_to_words.c new file mode 100644 index 0000000..1834e91 --- /dev/null +++ b/ex00/digits_to_words.c @@ -0,0 +1,12 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* digits_to_words.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/02 23:40:54 by achubuko #+# #+# */ +/* Updated: 2023/12/02 23:43:18 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "digits_to_words.h" diff --git a/ex00/digits_to_words.h b/ex00/digits_to_words.h new file mode 100644 index 0000000..7577b66 --- /dev/null +++ b/ex00/digits_to_words.h @@ -0,0 +1,14 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* digits_to_words.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/02 23:35:43 by achubuko #+# #+# */ +/* Updated: 2023/12/02 23:36:29 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef DIGITS_TO_WORDS_H +# define DIGITS_TO_WORDS_H +#endif diff --git a/ex00/ft_utils.c b/ex00/ft_utils.c index e19b593..c97ffe9 100644 --- a/ex00/ft_utils.c +++ b/ex00/ft_utils.c @@ -6,7 +6,7 @@ /* By: achubuko +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/02 21:56:30 by achubuko #+# #+# */ -/* Updated: 2023/12/02 22:41:05 by achubuko ### ########.fr */ +/* Updated: 2023/12/02 23:45:23 by achubuko ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_utils.h" @@ -15,3 +15,13 @@ uint32_t ft_atoui32(char *str) { return (*str - '0'); } + +size_t ft_strlen(char *s) +{ + size_t l; + + l = 0; + while (*s++) + l++; + return (l); +} diff --git a/ex00/main.c b/ex00/main.c index 895f8b9..babb3c2 100644 --- a/ex00/main.c +++ b/ex00/main.c @@ -6,7 +6,7 @@ /* By: achubuko +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/02 21:01:21 by achubuko #+# #+# */ -/* Updated: 2023/12/02 21:55:21 by achubuko ### ########.fr */ +/* Updated: 2023/12/02 23:45:57 by achubuko ### ########.fr */ /* */ /* ************************************************************************** */ #include "main.h" @@ -18,5 +18,5 @@ int main(int argc, char **argv) write(1, "Error: program requires 1 or 2 arguments passed!", 48); return (1); } - write(1, argv[1], 1); + write(1, argv[1], ft_strlen(argv[1])); } diff --git a/ex00/main.h b/ex00/main.h index 629aac5..95af0c0 100644 --- a/ex00/main.h +++ b/ex00/main.h @@ -6,12 +6,13 @@ /* By: achubuko +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/02 21:14:25 by achubuko #+# #+# */ -/* Updated: 2023/12/02 21:25:18 by achubuko ### ########.fr */ +/* Updated: 2023/12/02 23:43:11 by achubuko ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef MAIN_H # define MAIN_H # include # include - +# include "digits_to_words.h" +# include "ft_utils.h" #endif