-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
41 lines (38 loc) · 1.35 KB
/
Copy pathft_strjoin.c
File metadata and controls
41 lines (38 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gdannay <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/13 10:22:51 by gdannay #+# #+# */
/* Updated: 2017/12/02 11:46:17 by gdannay ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
size_t size1;
size_t size2;
char *new;
size_t i;
size_t j;
i = 0;
j = 0;
size1 = ft_strlen(s1);
size2 = ft_strlen(s2);
if ((new = (char *)malloc(sizeof(char) * (size1 + size2 + 1))) == NULL)
return (0);
while (s1 && s1[i] != '\0')
{
new[i] = s1[i];
i++;
}
while (s2 && s2[j] != '\0')
new[i++] = s2[j++];
new[i] = '\0';
return (new);
}