54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* strncpy.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/07/19 13:05:06 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
||
|
{
|
||
|
int i;
|
||
|
|
||
|
i = 0;
|
||
|
while (*src != '\0' && i < n)
|
||
|
{
|
||
|
*dest = *src;
|
||
|
src++;
|
||
|
dest++;
|
||
|
i++;
|
||
|
}
|
||
|
dest[n] = 0;
|
||
|
return (dest);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
char dest1[10];
|
||
|
char src1[10] = "test";
|
||
|
|
||
|
strncpy(dest1, src1, 2);
|
||
|
|
||
|
printf("%s", dest1);
|
||
|
|
||
|
|
||
|
printf("\n");
|
||
|
|
||
|
|
||
|
char dest2[10];
|
||
|
char src2[10] = "test";
|
||
|
|
||
|
ft_strncpy(dest2, src2, 2);
|
||
|
|
||
|
printf("%s", dest2);
|
||
|
}
|
||
|
*/
|