37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strncpy.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/03/19 10:25:26 by tischmid #+# #+# */
|
|
/* Updated: 2023/03/19 18:05:09 by tischmid ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
|
{
|
|
unsigned int i;
|
|
|
|
i = -1;
|
|
while (++i < n && src[i] != '\0')
|
|
dest[i] = src[i];
|
|
while (++i < n)
|
|
dest[i] = '\0';
|
|
return (dest);
|
|
}
|
|
|
|
/* ////
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
char s1[10];
|
|
|
|
ft_strncpy(s1, "Hello", 4);
|
|
printf("%s\n", s1);
|
|
return (0);
|
|
}
|
|
*/ ////
|