-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
38 lines (35 loc) · 1.2 KB
/
ft_strjoin.c
File metadata and controls
38 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jihyjeon < [email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/19 18:43:11 by jihyjeon #+# #+# */
/* Updated: 2023/11/05 21:59:30 by jihyjeon ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *new;
char *tmp;
new = (char *)malloc(sizeof(char) * (ft_strlen(s1) + ft_strlen(s2) + 1));
if (!(new))
return (0);
tmp = new;
while (*s1)
{
*tmp = *s1;
s1++;
tmp++;
}
while (*s2)
{
*tmp = *s2;
s2++;
tmp++;
}
*tmp = '\0';
return (new);
}