-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
33 lines (30 loc) · 1.26 KB
/
Copy pathft_strjoin.c
File metadata and controls
33 lines (30 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jwon <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/06 15:48:53 by jwon #+# #+# */
/* Updated: 2021/11/25 18:39:42 by kamanfo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
int idx;
int idx_join;
char *join;
join = malloc((ft_strlen((char *)s1) + ft_strlen((char *)s2) + 1));
if (!s1 || !s2 || !join)
return (NULL);
idx = 0;
idx_join = 0;
while (s1[idx])
join[idx_join++] = s1[idx++];
idx = 0;
while (s2[idx])
join[idx_join++] = s2[idx++];
join[idx_join] = '\0';
return (join);
}