init
This commit is contained in:
41
Correction/thellego/ex10/ft_strlcpy.c
Normal file
41
Correction/thellego/ex10/ft_strlcpy.c
Normal file
@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 09:44:45 by thellego #+# #+# */
|
||||
/* Updated: 2022/07/20 11:02:34 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (i < size - 1 && src[i] != '\0')
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
while (src[i] != '\0')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
char tab1[12] = "hello world";
|
||||
char tab[5] = "";
|
||||
printf("%s\n", tab);
|
||||
printf("%d\n", ft_strlcpy(tab, tab1, 11));
|
||||
printf("%s\n", tab1);
|
||||
printf("%s\n", tab);
|
||||
}
|
Reference in New Issue
Block a user