From 3e469787f99db709a7274a573f7002b76679480f Mon Sep 17 00:00:00 2001 From: whaffman Date: Fri, 6 Dec 2024 13:13:44 +0100 Subject: [PATCH] ft_count_words --- inc/libft.h | 1 + src/string/ft_split.c | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/libft.h b/inc/libft.h index 7814ae8..e40fcad 100644 --- a/inc/libft.h +++ b/inc/libft.h @@ -25,6 +25,7 @@ int ft_isdigit(int c); int ft_isalnum(int c); int ft_isascii(int c); int ft_isprint(int c); +int ft_count_words(char const *s, char c); size_t ft_strlen(const char *s); void *ft_memset(void *s, int c, size_t n); void ft_bzero(void *s, size_t n); diff --git a/src/string/ft_split.c b/src/string/ft_split.c index b87c0b9..deb3053 100644 --- a/src/string/ft_split.c +++ b/src/string/ft_split.c @@ -11,10 +11,9 @@ /* ************************************************************************** */ #include -#include #include "libft.h" -static int count_words(char const *s, char c) +int ft_count_words(char const *s, char c) { int n; int i; @@ -42,7 +41,7 @@ static void *free_arr(int n, char ***arr) /** * @brief ft_split() splits an array based on a seperator. - * + * * @param s is a string. * @param c is the seperator. * @return char** an array of string where the last element is NULL. @@ -54,7 +53,7 @@ char **ft_split(char const *s, char c) int i; int j; - result = malloc((count_words(s, c) + 1) * sizeof(char *)); + result = malloc((ft_count_words(s, c) + 1) * sizeof(char *)); if (!result) return (NULL); i = 0;