ft_strlcat.c

This commit is contained in:
Timo Schmidt 2023-03-27 00:48:40 +02:00
parent b590433a12
commit cea241ebc2
1 changed files with 45 additions and 0 deletions

45
ex05/ft_strlcat.c Normal file
View File

@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/24 03:19:16 by tischmid #+# #+# */
/* Updated: 2023/03/27 00:48:27 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
{
int src_len;
unsigned int i;
char *o_src;
o_src = src;
i = 0;
while (*dest++)
++i;
--dest;
while (++i < size && *src)
*dest++ = *src++;
*dest = 0;
src_len = 0;
while (*o_src++)
++src_len;
return (src_len);
}
#define START
#include <stdio.h>
int main(void)
{
char s[10] = "123";
printf("%d\n", ft_strlcat(s, "abc", 5));
printf("%s\n", s);
return (0);
}