-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcat.c
executable file
·29 lines (26 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luperez <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/07 00:18:10 by luperez #+# #+# */
/* Updated: 2014/11/07 01:29:21 by luperez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strcat(char *s1, const char *s2)
{
int len;
char *save;
len = ft_strlen(s1) + ft_strlen((char *)s2);
if ((s1 < s2 && s1 + len >= s2) || (s1 > s2 && s1 < s2 + len) || s1 == s2)
return (NULL);
save = s1;
s1 += ft_strlen(s1);
while (*s2)
*s1++ = *s2++;
*s1 = '\0';
return (save);
}