-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
52 lines (46 loc) · 1.59 KB
/
ft_strlcpy.c
File metadata and controls
52 lines (46 loc) · 1.59 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simarcha <simarcha@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:43:10 by simarcha #+# #+# */
/* Updated: 2024/06/21 15:22:33 by simarcha ### ########.fr */
/* */
/* ************************************************************************** */
//strlcpy function copies/crushes src into dst up to n - 1 (= here size - 1)
//values saving the Null terminated characters
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t size)
{
size_t i;
i = 0;
if (size > 0)
{
while (src[i] != '\0' && (i < size - 1))
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
}
return (ft_strlen(src));
}
/*#include <string.h>
#include <stdio.h>
int main(void)
{
int a;
int b;
char dst[] = "This is a test";
const char src[20] = "";
char sim_dst[] = "This is a test";
b = strlcpy(dst, src, 0);
printf("Lib : %s\n", dst);
printf("Lib : %d\n", b);
a = ft_strlcpy(sim_dst, src, 0);
printf("Sim : %s\n", sim_dst);
printf("Sim : %d\n", a);
return (0);
}*/