count_arr & is_digit_str

This commit is contained in:
whaffman 2025-02-20 15:55:38 +01:00
parent 8072c13f1e
commit 5944b0f811
4 changed files with 60 additions and 5 deletions

View File

@ -6,7 +6,7 @@
# By: whaffman <whaffman@student.codam.nl> +#+ #
# +#+ #
# 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))

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* 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 <stddef.h>
# 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

23
src/array/ft_count_arr.c Normal file
View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_count_arr.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* 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);
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_isdigit_str.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* 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);
}