-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strcat.c
executable file
·41 lines (36 loc) · 1.29 KB
/
ft_strcat.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
30
31
32
33
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/18 16:02:19 by akharrou #+# #+# */
/* Updated: 2019/05/02 15:17:31 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/libft.h"
char *ft_strcat(char *s1, const char *s2)
{
size_t i;
size_t j;
if (s2)
{
i = ft_strlen(s1);
j = 0;
while (s2[j])
s1[i++] = s2[j++];
s1[i] = '\0';
}
return (s1);
}
char *ft_strcatfre(char *s1, const char *s2, int free_s1, int free_s2)
{
char *ret;
ret = ft_strcat(s1, s2);
if (free_s1 && s1)
free((void *)s1);
if (free_s2 && s2)
free((void *)s2);
return (ret);
}