/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strjoin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet int ft_strlen(char *str) { char i; i = 0; while (str[i] != 0) i++; } char *ft_strcat(char *dest, char *src) { int i; int j; j = 0; i = 0; while (dest[i] != 0) i++; while (src[j] != 0) { dest[i + j] = src[j]; j++; } dest[i + j] = 0; return (dest); } char *ft_strjoin(int size, char **strs, char *sep) { int i; int word_counter; char *out; if (size == 0) { *out = malloc(sizeof(*out)); *out = ""; return (out); } i = 0; while (i < size) { word_counter += ft_strlen(strs[i]); word_counter += ft_strlen(sep); i++; } out = malloc(sizeof(*out) * word_counter); i = 0; while (i < size) { ft_strcat(out, strs[i++]); ft_strcat(out, sep); } return (out); }