#include <stdio.h>
#include <string.h>
int length(char *str)
{
int index;
index = 0;
while (str[index] != '\0')
{
index++;
}
return (index);
}
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
int index;
index = 0;
int len = length(dest);
while (src[index] != '\0' && index < nb)
{
dest[len] = src[index];
index++;
len++;
}
while (index < nb)
{
dest[len] = '\0';
index++;
}
return (dest);
}
int main() {
char dest[] = "Hello";
char src[] = "jdsw";
printf("%s\n",ft_strncat(dest, src, 20));
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: