Iam trying to reproduce the behaviour of strlcat in C,writing my own function.
I need to append string1 to the end of string2.
I start looping through string1 until it finds a '\0', and then I try to write string2 to string1 from there. However I think this is not the way to do it because it throw some segmentation fault and maybe Im acessing memor I shouldn't (?).
char *ft_srlcat(char *dst, char *src, int size) {
int i;
int j;
i = 0;
j = 0;
while (dst[i] != '\0')
{
i++;
}
while (size > 0 || src[j] != '\0')
{
dst[i] = src[j];
i++;
j++;
size--;
}
printf("%s\n", dst);
}
void main {
ft_strlcat("A very long", "teste to see if it works"), 5
}