ajout de main a join
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/25 14:01:26 by hulamy #+# #+# */
|
||||
/* Updated: 2019/12/04 15:30:57 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/12/04 16:55:43 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,37 @@
|
||||
** create a new string by concatenating the two strings s1 and s2
|
||||
*/
|
||||
|
||||
/*
|
||||
** #include <libc.h>
|
||||
**
|
||||
** size_t ft_strlen(const char *str)
|
||||
** {
|
||||
** size_t i;
|
||||
**
|
||||
** i = 0;
|
||||
** while (str[i])
|
||||
** i++;
|
||||
** return (i);
|
||||
** }
|
||||
**
|
||||
** char *ft_strjoin(char const *s1, char const *s2);
|
||||
**
|
||||
** int main(int ac, char **av)
|
||||
** {
|
||||
** char *s1;
|
||||
** char *s2;
|
||||
** char *str;
|
||||
**
|
||||
** if (ac != 3)
|
||||
** return (0);
|
||||
** s1 = strdup(av[1]);
|
||||
** s2 = strdup(av[2]);
|
||||
** str = ft_strjoin(s1, s2);
|
||||
** printf("%s\n", str);
|
||||
** return (0);
|
||||
** }
|
||||
*/
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static char *ft_doit(char const *s1, char const *s2, char *dest)
|
||||
@@ -24,18 +55,10 @@ static char *ft_doit(char const *s1, char const *s2, char *dest)
|
||||
j = 0;
|
||||
i = 0;
|
||||
while (s1[j] != '\0')
|
||||
{
|
||||
dest[i] = s1[j];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
dest[i++] = s1[j++];
|
||||
j = 0;
|
||||
while (s2[j] != '\0')
|
||||
{
|
||||
dest[i] = s2[j];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
dest[i++] = s2[j++];
|
||||
dest[i] = '\0';
|
||||
return (dest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user