Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
WOLFIE-OG committed Jun 24, 2024
1 parent 4e05cea commit 2e64d7e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: otodd <otodd@student.42london.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/02/13 17:49:05 by otodd #+# #+# #
# Updated: 2024/06/18 17:46:14 by otodd ### ########.fr #
# Updated: 2024/06/24 17:14:20 by otodd ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -143,6 +143,7 @@ UTIL_SRCS = $(UTIL_DIR)/ft_numlen.c \
$(UTIL_DIR)/ft_strarraylen.c \
$(UTIL_DIR)/ft_strarraystrcat.c \
$(UTIL_DIR)/ft_strarraychr.c \
$(UTIL_DIR)/ft_strarraytostr.c \
$(UTIL_DIR)/ft_file_extension.c \
$(UTIL_DIR)/ft_key_value.c

Expand Down
3 changes: 2 additions & 1 deletion include/libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: otodd <otodd@student.42london.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 18:36:11 by otodd #+# #+# */
/* Updated: 2024/06/18 14:23:44 by otodd ### ########.fr */
/* Updated: 2024/06/24 17:13:59 by otodd ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -163,6 +163,7 @@ char **ft_strarrayjoin(char **a1, char **a2);
char **ft_strarraydup(char **a);
char **ft_strarrayappend(char **a, char *s);
char *ft_strarraychr(char **a, char **c);
char *ft_strarraytostr(char **arr);
char *ft_file_extension(char *str);
char **ft_key_value(char const *s, char c);

Expand Down
41 changes: 41 additions & 0 deletions src/utils/ft_strarraytostr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strarraytostr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: otodd <otodd@student.42london.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/24 17:00:22 by otodd #+# #+# */
/* Updated: 2024/06/24 17:13:37 by otodd ### ########.fr */
/* */
/* ************************************************************************** */

#include "../../include/libft.h"

char *ft_strarraytostr(char **arr)
{
size_t t;
size_t i;
char *r;
char *h;

t = 0;
i = 0;

while (arr[i])
t += ft_strlen(arr[i++]);

r = malloc(sizeof(char) * t + 1);
if (!r)
return (NULL);
i = 0;
h = r;
while (arr[i])
{
t = ft_strlen(arr[i]);
ft_memcpy(h, arr[i++], t);
h += t;
}
*h = '\0';
return (r);
}

0 comments on commit 2e64d7e

Please sign in to comment.