-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
38 lines (34 loc) · 1.36 KB
/
ft_strlcpy.c
File metadata and controls
38 lines (34 loc) · 1.36 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
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fsanz-ex <fsanz-ex@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/22 20:32:19 by fsanz-ex #+# #+# */
/* Updated: 2023/02/14 15:19:42 by fsanz-ex ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*Copies up to dstsize - 1 characters from the string src to dst, NUL-terminat-
ing the result if dstsize is not 0. Return the total length of the string tried
to create (the length of src).*/
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
unsigned int i;
unsigned int l;
i = 0;
l = 0;
while (src[l] != '\0')
l++;
if (dstsize != 0)
{
while (src[i] != '\0' && i < dstsize - 1)
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
}
return (l);
}