-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
29 lines (26 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: javellis <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/28 10:40:54 by javellis #+# #+# */
/* Updated: 2022/07/28 10:40:58 by javellis ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <stddef.h>
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
size_t size;
size = ft_strlen(s2) + ft_strlen(s1) + 1;
str = (char *)malloc(size);
if (!str)
return (NULL);
ft_strlcpy(str, (char *)s1, size);
ft_strlcat(str, (char *)s2, size);
return (str);
}