-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdupcat.c
48 lines (43 loc) · 1.3 KB
/
ft_strdupcat.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
42
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdupcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thifranc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/10/26 12:03:38 by thifranc #+# #+# */
/* Updated: 2015/11/01 23:39:46 by alahlou ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
int ft_strlen2(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
char *ft_strdupcat(char *dest, char *src, int ct)
{
int i;
int j;
char *dest2;
j = 0;
i = 0;
dest2 = malloc(sizeof(char) * (ct * 10 + 1));
if (!dest2)
return (0);
while (dest[i] != '\0')
{
dest2[i] = dest[i];
i++;
}
while (src[j])
{
dest2[i + j] = src[j];
j++;
}
dest2[i + j] = '\0';
return (dest2);
}