init
This commit is contained in:
40
Correction/titou/ex05/ft_strlcat.c
Normal file
40
Correction/titou/ex05/ft_strlcat.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/21 13:02:29 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/25 10:49:16 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
i = 0;
|
||||
while (dest[i] != 0)
|
||||
i++;
|
||||
j = 0;
|
||||
while (src[j] != 0 && i < size)
|
||||
{
|
||||
dest[i + j] = src[j];
|
||||
j++;
|
||||
}
|
||||
dest[i + j] = '\0';
|
||||
return (j + i);
|
||||
}
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
char src[] = "hello";
|
||||
char dest2[5] = "fjff";
|
||||
int j;
|
||||
|
||||
j = ft_strlcat(src, dest2, 5);
|
||||
|
||||
printf("%d %s\n", j, dest2);
|
||||
}
|
Reference in New Issue
Block a user