-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlcpy.c
42 lines (39 loc) · 1.43 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
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gusgonza <gusgonza@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 15:30:29 by gusgonza #+# #+# */
/* Updated: 2024/02/12 15:53:43 by gusgonza ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t size)
{
size_t pos;
pos = 0;
if (size > 0)
{
while (pos < size - 1 && src[pos] != '\0')
{
dest[pos] = src [pos];
pos++;
}
dest[pos] = '\0';
}
return (ft_strlen(src));
}
/* //For testing
int main(void)
{
char str[] = "HellooBye";
char str2[] = "Helloo";
printf("strlcpy -> %ld\n", strlcpy(str, str2, 5));
printf("str-> %s\nstr2: %s\n", str, str2);
printf("ft_strlcpy: %ld\n", ft_strlcpy(str, str2, 5));
printf("ft_str: %s\nft_str2: %s\n", str, str2);
return (0);
}
*/