-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncat.c
30 lines (28 loc) · 1.15 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
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amahla <amahla@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/14 11:12:54 by amahla #+# #+# */
/* Updated: 2022/03/14 14:44:11 by amahla ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
unsigned int i;
unsigned int j;
i = 0;
j = 0;
while (dest && *(dest + i))
i++;
while (src && *(src + j) && j < nb)
{
*(dest + i + j) = *(src + j);
j++;
}
if (i + j < nb)
*(dest + j) = '\0';
return (dest);
}