43 lines
1.3 KiB
C
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);
|
|
}
|
|
*/
|