ft_strncpy.c

This commit is contained in:
Timo Schmidt 2023-03-19 10:32:01 +01:00
parent c2b7cd3280
commit 3a3fb2e0e3
1 changed files with 41 additions and 0 deletions

41
ex01/ft_strncpy.c Normal file
View File

@ -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);
}
*/ ////