piscine/c02/ex01/ft_strncpy.c
Willem Haffmans 607ce08c18 all
2024-09-10 00:18:01 +02:00

43 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/06 12:11:53 by whaffman #+# #+# */
/* Updated: 2024/06/06 18:14:49 by whaffman ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (src[i] != '\0' && i < n)
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}
/*
#include <stdio.h>
int main(void)
{
char src[] = "Held!";
char dest[] = "World, Hello!";
printf("%s",&dest[0]);
ft_strncpy(&dest[0], &src[0], 6);
printf("%s",&dest[0]);
return (0);
}
*/