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

Go to the source code of this file.

Functions

size_t ft_strlcat (char *dest, const char *src, size_t size)
 Appends a string to a bounded destination buffer.
 

Function Documentation

◆ ft_strlcat()

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

Appends a string to a bounded destination buffer.

Parameters
destDestination buffer.
srcSource string.
sizeFull size of dest buffer.
Returns
Length of the string it tried to create.

Definition at line 23 of file ft_strlcat.c.

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

References ft_strlen().

+ Here is the call graph for this function: