-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
55 lines (50 loc) · 1.6 KB
/
Copy pathft_strlcpy.c
File metadata and controls
55 lines (50 loc) · 1.6 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
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpadenko <dpadenko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/06 20:14:33 by dpadenko #+# #+# */
/* Updated: 2023/09/17 21:09:44 by dpadenko ### ########.fr */
/* */
/* ************************************************************************** */
//#include <stdlib.h>
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, unsigned int size)
{
size_t i;
i = 0;
if (size == 0)
return (ft_strlen(src));
while (src[i] != '\0' && (i < size - 1))
{
dest[i] = src[i];
i++;
}
dest [i] = '\0';
return (ft_strlen(src));
}
/*
int main(int argc, char *argv[])
{
//unsigned int length;
//char a[atoi(argv[1])];
if (argc != 4)
return (0);
printf("%d", ft_strlcpy(argv[1], argv[2], atoi(argv[3])));
//printf("\n%s\n", argv[1]);
//print("%d", length);
}
*/
/*
int main(void)
{
char string[] = "abcdef";
char pointed_buffer[10];
unsigned int size = 10;
unsigned int length;
length = ft_strlcpy(pointed_buffer, string, 10);
printf("%d", length);
}
*/