-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
61 lines (56 loc) · 1.57 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sakllam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/30 15:45:19 by sakllam #+# #+# */
/* Updated: 2021/12/05 19:03:10 by sakllam ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
char *ft_strjoinbeta(char const *s1, char const *s2)
{
int i;
int k;
int count;
char *p;
if (!s1 || !s2)
return (NULL);
i = ft_strlen(s1);
k = ft_strlen(s2);
count = i + k + 2;
p = (char *) malloc(count * sizeof(char));
if (!p)
return (NULL);
i = 0;
k = i;
while (s1[k])
p[i++] = s1[k++];
p[i++] = '/';
k = 0;
while (s2[k])
p[i++] = s2[k++];
p[i] = '\0';
return (p);
}
char *ft_strjoinalfa(char const *s1)
{
int i;
int count;
char *p;
if (!s1)
return (NULL);
i = ft_strlen(s1);
count = i + 2;
p = (char *) malloc(count * sizeof(char));
if (!p)
return (NULL);
i = -1;
while (s1[++i])
p[i] = s1[i];
p[i++] = '\n';
p[i] = '\0';
return (p);
}