// #include <stdio.h>
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n && src[i])
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}
#include <stdio.h>
#include <string.h>
int main (void)
{
char dest[] = "Bye";
char src[] = "Hello";
printf("avant src= %s et dest= %s\n", src, dest);
ft_strncpy(dest, src, 5);
printf("apres src= %s et dest= %s\n", src, dest);
printf("avec vrai fonction %s\n", strncpy(dest, src, 5));
return (0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: