init
This commit is contained in:
BIN
Correction/levv/ex10/a.out
Executable file
BIN
Correction/levv/ex10/a.out
Executable file
Binary file not shown.
39
Correction/levv/ex10/ft_strlcpy.c
Normal file
39
Correction/levv/ex10/ft_strlcpy.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/21 14:13:53 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/21 18:25:55 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strlcpy(char *dest, char *src, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (src[i] != '\0' && dest[i] != '\0' && i < n)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
while (i < n && dest[i] != '\0')
|
||||
{
|
||||
dest[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <bsd/string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char src[42] = "jetest";
|
||||
char dest[42];
|
||||
printf("%d\n", ft_strlcpy(dest, src, 4));
|
||||
printf("%ld", strlcpy(dest, src, 4));
|
||||
}
|
Reference in New Issue
Block a user