-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncat.c
25 lines (22 loc) · 1.11 KB
/
ft_strncat.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mschumac <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/16 19:15:58 by mschumac #+# #+# */
/* Updated: 2017/07/01 01:36:27 by mschumac ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncat(char *s1, const char *s2, size_t n)
{
size_t len_s1;
len_s1 = ft_strlen(s1);
if (n >= ft_strlen(s2))
return (ft_strcat(s1, s2));
ft_strncpy(s1 + len_s1, s2, n);
s1[len_s1 + n] = '\0';
return (s1);
}