-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
29 lines (26 loc) · 1.2 KB
/
ft_strjoin.c
File metadata and controls
29 lines (26 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpeters <tpeters@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/26 17:28:35 by tpeters #+# #+# */
/* Updated: 2022/04/08 15:17:17 by tpeters ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *sub;
unsigned int tot_size;
if (!s1 || !s2)
return (NULL);
tot_size = ft_strlen(s1) + ft_strlen(s2) + 1;
sub = (char *) malloc (tot_size);
if (!sub)
return (NULL);
ft_strlcpy(sub, s1, tot_size);
ft_strlcat(sub, s2, tot_size);
return (sub);
}