UtilLib
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hexplor <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 17:27:30 by hexplor #+# #+# */
|
||||
/* Updated: 2023/11/09 20:22:10 by hexplor ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
size_t ft_strlcpy(char *dest, const char *src, size_t size)
|
||||
{
|
||||
size_t c;
|
||||
size_t i;
|
||||
|
||||
c = 0;
|
||||
while (src[c] != '\0')
|
||||
c++;
|
||||
i = 0;
|
||||
if (size != 0)
|
||||
{
|
||||
while (src[i] != '\0' && i < (size - 1))
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
/*int main()
|
||||
{
|
||||
char dest[10] = "oui";
|
||||
char src[3] = "non";
|
||||
|
||||
ft_strlcpy(dest, src, 10);
|
||||
return (0);
|
||||
}*/
|
||||
Reference in New Issue
Block a user