42_libft/ft_strlcat.c

26 lines
1.2 KiB
C
Raw Normal View History

2022-09-27 11:25:41 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 17:02:13 by cchauvet #+# #+# */
2022-10-04 08:21:55 -04:00
/* Updated: 2022/09/28 17:11:29 by cchauvet ### ########.fr */
2022-09-27 11:25:41 -04:00
/* */
/* ************************************************************************** */
#include "libft.h"
2022-10-04 08:21:55 -04:00
size_t ft_strlcat(char *dest, const char *src, size_t size)
2022-09-27 11:25:41 -04:00
{
2022-10-04 08:21:55 -04:00
size_t len_dest;
2022-09-27 11:25:41 -04:00
2022-10-04 08:21:55 -04:00
if (size == 0)
return (ft_strlen(src));
len_dest = ft_strlen(dest);
if (len_dest >= size)
return (ft_strlen(src) + (size));
return (len_dest + ft_strlcpy(dest + len_dest, src, size - len_dest));
2022-09-27 11:25:41 -04:00
}