ft_strncpy.c
This commit is contained in:
parent
c2b7cd3280
commit
3a3fb2e0e3
|
@ -0,0 +1,41 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strncpy.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/03/19 10:25:26 by tischmid #+# #+# */
|
||||||
|
/* Updated: 2023/03/19 10:30:45 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);
|
||||||
|
}
|
||||||
|
*/ ////
|
Loading…
Reference in New Issue