-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_strlcpy.c
45 lines (41 loc) · 1.44 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
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jede-ara <jede-ara@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/02 15:37:04 by jede-ara #+# #+# */
/* Updated: 2022/11/08 14:29:43 by jede-ara ### ########.fr */
/* */
/* ************************************************************************** */
/*
DESCRIÇÃO: strlcpy() copia strings, considera o tamanho total de memória para
a string e garante terminar a string incluindo o byte NULL.
*/
#include "libft.h"
size_t ft_strlcpy(char *dest, const char *src, size_t size)
{
size_t i;
size_t x;
x = ft_strlen(src);
i = 0;
if (size != 0)
{
while (src [i] != '\0' && i < size - 1)
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
}
return (x);
}
/*#include <stdio.h>
int main(void)
{
const char src[] = "Oliveira";
char dest[] = "Jennifer";
unsigned int n = 10;
printf("%ld\n", ft_strlcpy(dest, src, n));
}*/