#include <stdlib.h>
#include <stdio.h>
char *my_strncat(char *dest, char const *src, int nb)
{
int i = 0;
int j = 0;
if (dest == NULL || src == NULL) {
return NULL;
}
if (nb < 0) {
return dest;
}
while (dest[i] != '\0') {
i++;
}
while (j < nb && src[j] != '\0') {
dest[i] = src[j];
i++;
j++;
}
dest[i] = '\0';
return dest;
}
int main()
{
char dest[50] = "Hello";
my_strncat(dest, "World", 8);
printf("Résultat : %s\n", dest);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: