-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
executable file
·38 lines (35 loc) · 1.3 KB
/
ft_strjoin.c
File metadata and controls
executable file
·38 lines (35 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zdnaya <zdnaya@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/22 10:06:34 by zdnaya #+# #+# */
/* Updated: 2019/11/11 15:34:58 by zdnaya ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *s3;
char *str1;
char *str2;
unsigned int len;
if (!s1 || !s2)
{
return (NULL);
}
str1 = (char *)s1;
str2 = (char *)s2;
len = 0;
s3 = (char *)malloc(ft_strlen(str1) + ft_strlen(str2) + 1);
if (s3 == NULL)
return (NULL);
while (*str1)
s3[len++] = *(str1++);
while (*str2)
s3[len++] = *(str2++);
s3[len] = '\0';
return (s3);
}