-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
36 lines (32 loc) · 1.27 KB
/
ft_strlcpy.c
File metadata and controls
36 lines (32 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kmoutaou <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/07 10:48:32 by kmoutaou #+# #+# */
/* Updated: 2021/11/22 09:38:47 by kmoutaou ### ########.fr */
/* */
/* ************************************************************************** */
/*
ft_strlcpy is a re-coded -strlcpy- function from <bsd/string.h> that copies
src (n - 1 charachters) to dest of size n and returns the number of
characters in src.
*/
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t n)
{
unsigned int i;
i = 0;
if (n != 0)
{
while (src[i] && i < n - 1)
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
}
return (ft_strlen(src));
}