48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strncpy.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
|
/* Updated: 2022/07/20 13:25:33 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
|
{
|
|
unsigned int i;
|
|
|
|
i = 0;
|
|
while (*src != '\0' || i < n)
|
|
{
|
|
*dest = *src;
|
|
src++;
|
|
dest++;
|
|
i++;
|
|
}
|
|
return (dest);
|
|
}
|
|
|
|
void ft_print(char *str)
|
|
{
|
|
while (*str != 0)
|
|
{
|
|
write(1, str++, 1);
|
|
}
|
|
}
|
|
|
|
/*
|
|
int main(void)
|
|
{
|
|
char *a;
|
|
char b[6];
|
|
|
|
b[5] = 'd';
|
|
a = "00000";
|
|
ft_strncpy(b, a, 5);
|
|
ft_print(b);
|
|
}
|
|
*/
|