This commit is contained in:
Jack Halford 2016-12-10 18:25:36 +01:00
parent 15654a8b1a
commit e0af98efbd
4 changed files with 41 additions and 3 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
/* Updated: 2016/12/09 22:11:49 by jhalford ### ########.fr */
/* Updated: 2016/12/10 17:02:46 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -145,6 +145,7 @@ void ft_sstrprint_fd(int fd, char **list, char sep);
char **ft_sstrdup(char **list);
void ft_sstrdel(char **sstr, int index);
void ft_sstrfree(char **sstr);
char *ft_sstrcat(char **sstr, char sep);
char *ft_path_notdir(char *path);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
/* Updated: 2016/12/09 22:10:32 by jhalford ### ########.fr */
/* Updated: 2016/12/10 16:50:26 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */
/* Updated: 2016/12/09 19:13:57 by jhalford ### ########.fr */
/* Updated: 2016/12/10 16:51:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sstrcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 16:58:06 by jhalford #+# #+# */
/* Updated: 2016/12/10 17:03:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_sstrcat(char **sstr, char sep)
{
int len;
int i;
char *out;
i = 0;
len = 0;
if (!sstr)
return (NULL);
while (sstr[i])
len += ft_strlen(sstr[i++]);
if (!(out = ft_strnew(sizeof(char) * (len + i + 1))))
return (NULL);
ft_strcat(out, sstr[0]);
i = 1;
while (sstr[i])
{
ft_strcat(out, (char[]){sep, 0});
ft_strcat(out, sstr[i]);
}
return (out);
}