-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
47 lines (43 loc) · 1.32 KB
/
ft_strjoin.c
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
39
40
41
42
43
44
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: azaghlou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/11 15:47:37 by azaghlou #+# #+# */
/* Updated: 2022/11/05 11:35:28 by azaghlou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
char *ft_strjoin(char const *s1, char const *s2)
{
char *ss;
int i;
int j;
i = 0;
j = 0;
ss = malloc(sizeof(char) * (ft_strlen(s1) + ft_strlen(s2) + 1));
if (!ss)
return (0);
while (s1[i])
{
ss[i] = s1[i];
i++;
}
while (s2[j])
{
ss[i] = s2[j];
j++;
i++;
}
ss[i] = '\0';
return (ss);
}
int main()
{
char *s1 = "amine";
char *s2 = "zaghloul";
printf("%s",ft_strjoin(s1, s2));
}