-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
37 lines (34 loc) · 1.47 KB
/
ft_strjoin.c
File metadata and controls
37 lines (34 loc) · 1.47 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
30
31
32
33
34
35
36
37
/*
███▄ ▄███▓▓█████ ███▄ █ ▄▄▄ ██████▓██ ██▓
▓██▒▀█▀ ██▒▓█ ▀ ██ ▀█ █ ▒████▄ ▒██ ▒ ▒██ ██▒
▓██ ▓██░▒███ ▓██ ▀█ ██▒▒██ ▀█▄ ░ ▓██▄ ▒██ ██░
▒██ ▒██ ▒▓█ ▄ ▓██▒ ▐▌██▒░██▄▄▄▄██ ▒ ██▒ ░ ▐██▓░
▒██▒ ░██▒░▒████▒▒██░ ▓██░ ▓█ ▓██▒▒██████▒▒ ░ ██▒▓░
░ ▒░ ░ ░░░ ▒░ ░░ ▒░ ▒ ▒ ▒▒ ▓▒█░▒ ▒▓▒ ▒ ░ ██▒▒▒
░ ░ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ▒▒ ░░ ░▒ ░ ░▓██ ░▒░
░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ▒ ▒ ░░
░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░*/
#include "libft.h"
#include <stdio.h>
char *ft_strjoin(char const *s1, char const *s2)
{
size_t i;
size_t lens1;
char *dst;
lens1 = ft_strlen(s1);
i = -1;
dst = malloc(sizeof(char) * (lens1 + ft_strlen(s2) + 1));
if (dst == NULL)
return (NULL);
while (s1[++i])
dst[i] = (char )s1[i];
i = -1;
while (s2[++i])
{
dst[lens1] = s2[i];
lens1++;
}
dst[lens1] = '\0';
return (dst);
}