style: reoarginsed the file and fix the makefile
This commit is contained in:
parent
ecd9608320
commit
a5fe7484a1
46 changed files with 140 additions and 49 deletions
49
str/ft_strlcat.c
Normal file
49
str/ft_strlcat.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 22:28:26 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 11:45:52 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static size_t ft_strnlen(char *dest, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (i < size && dest[i] != '\0')
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
size_t ft_strlcat(char *dest, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t destlen;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
destlen = ft_strnlen(dest, size);
|
||||
while (i < size && dest[i])
|
||||
i++;
|
||||
if (i == size)
|
||||
return (i + ft_strlen(src));
|
||||
while (src[j])
|
||||
{
|
||||
if (j < size - destlen - 1)
|
||||
{
|
||||
dest[i] = src[j];
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
return (destlen + j);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue