-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcat.c
39 lines (36 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mskeleto <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/07 07:17:01 by mskeleto #+# #+# */
/* Updated: 2021/12/07 07:17:04 by mskeleto ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
char *ft_strcat(char *dest, const char *src)
{
char *new_str;
int i;
int j;
i = 0;
j = 0;
new_str = (char *)malloc(ft_strlen(dest) + ft_strlen(src) + 2);
while (dest != NULL && (dest[j] != '\0'))
{
new_str[j] = dest[j];
j++;
}
new_str[j] = '/';
j++;
while (src != NULL && src[i] != '\0')
{
new_str[j] = src[i];
i++;
j++;
}
new_str[j] = '\0';
return (new_str);
}