-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
executable file
·31 lines (28 loc) · 1.21 KB
/
ft_strjoin.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhouser <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/09/29 11:59:54 by mhouser #+# #+# */
/* Updated: 2017/09/29 12:00:00 by mhouser ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(const char *s1, const char *s2)
{
int strlen;
char *str;
strlen = 0;
while (*((s1++) + 1))
strlen++;
while (*((s2++) + 1))
strlen++;
str = (char *)malloc(sizeof(char) * ((++strlen) + 2));
str[++strlen] = '\0';
while (strlen--)
str[strlen] = (*(s2 - 1)) ? *(--s2) : *(--s1);
return (str);
}
//