Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_strlcpy.c File Reference
+ Include dependency graph for ft_strlcpy.c:

Go to the source code of this file.

Functions

size_t ft_strlcpy (char *dest, const char *src, size_t size)
 Copies a string into a bounded destination buffer.
 

Function Documentation

◆ ft_strlcpy()

size_t ft_strlcpy ( char *  dest,
const char *  src,
size_t  size 
)

Copies a string into a bounded destination buffer.

Parameters
destDestination buffer.
srcSource string.
sizeSize of dest buffer.
Returns
Total length of src.

Definition at line 23 of file ft_strlcpy.c.

24{
25 size_t src_len;
26 size_t i;
27
28 src_len = ft_strlen(src);
29 if (size > 0)
30 {
31 i = 0;
32 while (src[i] && i < (size - 1))
33 {
34 dest[i] = src[i];
35 i++;
36 }
37 dest[i] = '\0';
38 }
39 return (src_len);
40}
size_t ft_strlen(const char *str)
Returns the length of a null-terminated string.
Definition ft_strlen.c:21

References ft_strlen().

Referenced by ft_substr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: