#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;
int len;
index = 0;
len = length(dest);
while (src[index] != '\0' && index < nb)
{
dest[len] = src[index];
index++;
len++;
}
dest[len] = '\0';
/*while (index < nb)
{
dest[len] = '\0';
index++;
}*/
return (dest);
}
int main() {
char dest[] = "Hello";
char dest1[] = "Hello";
char src[] = "jdswjhu";
char src1[] = "jdswjhu";
//printf("%s\n",ft_strncat(dest, src, 3));
printf("%s\n",strncat(dest1, src1, 3));
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: