-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
43 lines (40 loc) · 1.37 KB
/
ft_strjoin.c
File metadata and controls
43 lines (40 loc) · 1.37 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
39
40
41
42
43
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_strjoin.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: thperchi <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/07/12 05:24:49 by thperchi #+# ## ## #+# */
/* Updated: 2018/10/11 15:51:11 by thperchi ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
unsigned int x;
unsigned int y;
char *str;
x = 0;
y = 0;
if (s1 == NULL || s2 == NULL)
return (NULL);
while (s1[x])
x++;
while (s2[y])
y++;
if (!(str = malloc(sizeof(char *) * (x + y))))
return (NULL);
x = 0;
y = 0;
while (s1[x])
{
str[x] = s1[x];
x++;
}
while (s2[y])
str[x++] = s2[y++];
str[x] = '\0';
return (str);
}