Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
668 B
2
Indexable
Never
unsigned int	ft_strlcat(char *dest, char *src, unsigned int size)
{
	unsigned int	i;
	unsigned int	total;
	unsigned int	j;

	i = 0;
	j = 0;
	total = 0;
	while (dest[i] != '\0')
		i++;
	while (src[j] != '\0')
		j++;
	if (size < i)
		total = j + size;
	else
		total = j + i;
	while (*src && size != 0 && (i < (size - 1)))
	{
		dest[i] = *src;
		src++;
		i++;
	}
	dest[i] = 0;
	return (total);
}
#include <bsd/string.h>
#include <stdio.h>
int main(void)
{
	char dest[] = "Pompam";
	char src[] = "Moemoe";
	unsigned int i = 0;
	unsigned int j = 5;
	
	i = strlcat(dest, src,j);
	printf("\nsize: %d",j);
	printf("\nstrlcat: %d\n",i);

	printf("%s\n", dest);
	
	return (0);
}