This repository was archived by the owner on Aug 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strlcpy.c
More file actions
33 lines (29 loc) · 1.27 KB
/
ft_strlcpy.c
File metadata and controls
33 lines (29 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: inwagner <inwagner@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 18:10:56 by inwagner #+# #+# */
/* Updated: 2023/06/09 18:38:24 by inwagner ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t len)
{
size_t i;
if (!dst || !src)
return (0);
if (!len)
return (ft_strlen(src));
i = -1;
while (src[++i] && i < len - 1)
dst[i] = src[i];
dst[i] = '\0';
return (ft_strlen(src));
}
/*
Copia até `size - 1` bytes de `src` para `dst` adicionando um nulo no final.
Retorna o tamanho total da string que tentou criar.
*/