41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strlcpy.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/03/19 11:49:46 by tischmid #+# #+# */
|
|
/* Updated: 2023/03/21 09:44:10 by tischmid ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
|
|
{
|
|
unsigned int i;
|
|
|
|
i = -1;
|
|
while (*src && ++i < size - 1)
|
|
*dest++ = *src++;
|
|
*dest = 0;
|
|
return (i);
|
|
}
|
|
|
|
/* ////
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
char buf2[10];
|
|
char buf[2];
|
|
char str[] = {'A','B','C','D','E','\0'};
|
|
|
|
ft_strlcpy(buf, str, 6);
|
|
printf("%p\n", buf);
|
|
printf("%s\n", buf);
|
|
printf("%p\n", buf2);
|
|
printf("%s\n", buf2);
|
|
return (0);
|
|
}
|
|
*/ ////
|