My goal is to recreate the strcat() function without libraries:
#include <stdio.h>
char *ft_strcat(char *dest, char *src)
{
int i;
int j;
i = 0;
j = 0;
while (dest[i] != '\0')
{
i++;
}
while (src[j] != '\0')
{
dest[i] += src[j];
i++;
j++;
}
return (dest);
}
int main()
{
char destination[] = "hello ";
char source[] = "world";
printf("%s", ft_strcat(destination, source));
}
That's working but I got this encoding problem:
$ > ./a.out
hello wo"�o%
$ > ./a.out
hello wo"�Mj%
$ > ./a.out
hello wo"�Fn%

destination? What is the size of"hello world"? Can the latter fit in the first one?