maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strlcpy.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_strlcpy.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/12/17 17:25:27 by rmikhayl #+# #+# */
9
/* Updated: 2023/12/17 17:25:27 by rmikhayl ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
/* *************************** ft_strlcpy *********************************** */
16
/* Copies text from 'src' to 'dst' ensuring it fits within 'size' */
17
/* characters. Returns the length of the copied text. If something's */
18
/* missing or 'size' is too small, it won't work as intended. */
19
/* */
20
/* In layman's terms: It's like copying a passage from one page to another, */
21
/* making sure it fits without cutting off any words. If there's not enough */
22
/* space or some content is missing, it won't be a perfect copy. */
23
/* ************************************************************************** */
24
25
size_t
ft_strlcpy
(
char
*dst,
const
char
*src,
size_t
size)
26
{
27
char
*d;
28
const
char
*s;
29
size_t
n;
30
31
d = dst;
32
s = src;
33
n = size;
34
if
(n > 0)
35
{
36
while
(--n > 0 && *s !=
'\0'
)
37
*d++ = *s++;
38
*d =
'\0'
;
39
}
40
while
(*s !=
'\0'
)
41
s++;
42
return
(s - src);
43
}
ft_strlcpy
size_t ft_strlcpy(char *dst, const char *src, size_t size)
Definition
ft_strlcpy.c:25
libft.h
lib
libft
src
ft_strlcpy.c
Generated by
1.9.8