unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
// Bounds Check, check that dest >= src.
// Return the size of src.
unsigned int i;
unsigned int src_size;
i = 0;
src_size = 0;
while(src[src_size]!= '\0') // Count src size
{
src_size++;
}
if(size != 0)
{
while (src[i] != '\0' && i < size -1) //Copy
{
dest[i] = src[i];
i++;
}
}
dest[i] = '\0';
return src_size;
}
#include <stdio.h>
int main()
{
char dst[10];
char *src = "0123456789ABCDEF";
int len;
len = ft_strlcpy(dst, src, 0);
printf("Copied %d characters: %s\n", len, dst);
printf("%s", dst);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: