#include <stdio.h>
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n && src[i] != '\0')
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
return (dest);
}
int main(void)
{
char dest[15];
char *src;
unsigned int n;
src = "Hello World!";
n = 5;
printf("Avant : %s \n", dest);
ft_strncpy(dest, src, n);
printf("Apres : %s \n", dest);
return (0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: