-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlcpy.c
43 lines (40 loc) · 1.53 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pix <pix@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/18 00:07:10 by stales #+# #+# */
/* Updated: 2022/04/04 03:03:28 by pix ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copy strings. copies up to size - 1 characters from the
* NULL-terminated string src to dst, NUL-terminating the
* result.
*
* @param dest String to copy on
* @param src String to copy from
* @param size Full size of dest
*
* @return (t_uint32)The ft_strlcat() function return the total length of the
* string he tried to create. that means the length of src.
*/
t_uint32 ft_strlcpy(char *dest, char *src, t_size size)
{
char *tmp;
t_uint32 i;
tmp = src;
while (*tmp)
tmp++;
i = tmp - src;
if (!size)
return (i);
tmp = dest;
while (--size && *src)
*dest++ = *src++;
*dest = 0;
return (i);
}