forked from josanri/Libft_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
38 lines (35 loc) · 1.42 KB
/
ft_strlcpy.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
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aalvarez <aalvarez@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/16 22:11:44 by aalvarez #+# #+# */
/* Updated: 2022/08/19 22:13:26 by aalvarez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief copies up to dstsize - 1 bytes from the string pointed by src to
* the string pointed by dst.
*
* @param dst the new string.
* @param src the string to be copied.
* @param dstsize the size of the destination string.
* @return size_t the size of the string to be copied.
*/
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
if (!src || !dst)
return (0);
i = -1;
if (dstsize != 0)
{
while (src[++i] && i < dstsize - 1)
dst[i] = src[i];
dst[i] = 0;
}
return (ft_strlen(src));
}