Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
39
libft/ft_strjoin.c
Normal file
39
libft/ft_strjoin.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strjoin.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/13 20:16:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
char *ft_strjoin(char const *s1, char const *s2)
|
||||
{
|
||||
size_t i;
|
||||
size_t save_i;
|
||||
char *str;
|
||||
|
||||
i = 0;
|
||||
str = (char *)malloc((ft_strlen(s1) + ft_strlen(s2)) + 1);
|
||||
if (!str)
|
||||
return (NULL);
|
||||
while (s1[i] != '\0')
|
||||
{
|
||||
str[i] = s1[i];
|
||||
i++;
|
||||
}
|
||||
save_i = i;
|
||||
i = 0;
|
||||
while (s2[i] != '\0')
|
||||
{
|
||||
str[save_i + i] = s2[i];
|
||||
i++;
|
||||
}
|
||||
str[i + save_i] = '\0';
|
||||
return (str);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue