summaryrefslogtreecommitdiff
path: root/libft/ft_strlcat.c
diff options
context:
space:
mode:
Diffstat (limited to 'libft/ft_strlcat.c')
-rw-r--r--libft/ft_strlcat.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libft/ft_strlcat.c b/libft/ft_strlcat.c
new file mode 100644
index 0000000..cd1f70b
--- /dev/null
+++ b/libft/ft_strlcat.c
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strlcat.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2022/09/27 09:02:56 by kdx #+# #+# */
+/* Updated: 2022/09/28 17:03:21 by kdx ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+size_t ft_strlcat(char *dst, const char *src, size_t size)
+{
+ size_t dest_size;
+
+ if (size == 0)
+ return (ft_strlen(src));
+ dest_size = ft_strlen(dst);
+ if (dest_size >= size)
+ return (ft_strlen(src) + size);
+ return (dest_size + ft_strlcpy(dst + dest_size, src, size - dest_size));
+}