diff --git a/Makefile b/Makefile index 7628f53..3e491e9 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: whaffman +#+ # # +#+ # # Created: 2024/10/10 16:44:36 by whaffman #+# #+# # -# Updated: 2025/02/05 12:43:55 by whaffman ######## odam.nl # +# Updated: 2025/02/20 15:45:15 by whaffman ######## odam.nl # # # # **************************************************************************** # @@ -23,7 +23,9 @@ WARNINGS = -Wall -Wextra -Werror -g -fsanitize=address,undefined CFLAGS = $(WARNINGS) VPATH = src:src/conversion:src/ft_printf:src/list:src/memory:src/output:\ - src/string:src/get_next_line + src/string:src/get_next_line:src/array + +SRC_ARRAY = ft_count_arr.c SRC_CONVERSION = ft_atoi.c ft_itoa.c ft_tolower.c ft_toupper.c \ @@ -34,7 +36,7 @@ SRC_STRING = ft_isalnum.c ft_isalpha.c ft_isascii.c ft_isdigit.c ft_isprint.c \ ft_split.c ft_strchr.c ft_strdup.c ft_striteri.c ft_strjoin.c \ ft_strlcat.c ft_strlcpy.c ft_strlen.c ft_strmapi.c ft_strncmp.c \ ft_strnstr.c ft_strrchr.c ft_strtrim.c ft_substr.c ft_strcmp.c \ - ft_count_words.c ft_isspace.c + ft_count_words.c ft_isspace.c ft_isdigit_str.c SRC_LIST = ft_lstadd_back.c ft_lstadd_front.c ft_lstclear.c ft_lstdelone.c \ ft_lstiter.c ft_lstlast.c ft_lstmap.c ft_lstnew.c ft_lstsize.c @@ -49,7 +51,8 @@ SRC_FT_PRINTF = ft_isbase.c ft_putnbr_base.c ft_write_str.c parse_placeholder.c SRC_GET_NEXT_LINE = get_next_line.c SOURCES = $(SRC_CONVERSION) $(SRC_MEMORY) $(SRC_STRING) \ - $(SRC_LIST) $(SRC_OUTPUT) $(SRC_FT_PRINTF) $(SRC_GET_NEXT_LINE) + $(SRC_LIST) $(SRC_OUTPUT) $(SRC_FT_PRINTF) \ + $(SRC_GET_NEXT_LINE) $(SRC_ARRAY) OBJECTS = $(addprefix $(OBJ_DIR)/, $(SOURCES:.c=.o)) diff --git a/inc/libft.h b/inc/libft.h index 5015cbc..57022cd 100644 --- a/inc/libft.h +++ b/inc/libft.h @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2024/07/06 11:15:10 by whaffman #+# #+# */ -/* Updated: 2025/02/05 15:50:56 by whaffman ######## odam.nl */ +/* Updated: 2025/02/20 15:43:33 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -14,6 +14,9 @@ # define LIBFT_H # include +# define TRUE 1 +# define FALSE 0 + typedef struct s_list { void *content; @@ -58,6 +61,8 @@ void ft_putstr_fd(const char *s, int fd); void ft_putendl_fd(const char *s, int fd); void ft_putnbr_fd(const int n, int fd); void ft_free_arr(char **arr); +int ft_isdigit_str(char *str); +int ft_count_arr(char **arr); /* * Lists diff --git a/src/array/ft_count_arr.c b/src/array/ft_count_arr.c new file mode 100644 index 0000000..c4801ee --- /dev/null +++ b/src/array/ft_count_arr.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* ft_count_arr.c :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/02/20 15:42:41 by whaffman #+# #+# */ +/* Updated: 2025/02/20 15:43:17 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_count_arr(char **arr) +{ + int i; + + i = 0; + while (arr[i] != NULL) + i++; + return (i); +} diff --git a/src/string/ft_isdigit_str.c b/src/string/ft_isdigit_str.c new file mode 100644 index 0000000..012c748 --- /dev/null +++ b/src/string/ft_isdigit_str.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* ft_isdigit_str.c :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/02/20 15:40:24 by whaffman #+# #+# */ +/* Updated: 2025/02/20 15:41:00 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isdigit_str(char *str) +{ + while (*str) + { + if (!ft_isdigit(*str)) + return (FALSE); + str++; + } + return (TRUE); +}