-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncpy.c
44 lines (39 loc) · 1.28 KB
/
ft_strncpy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: davgalle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/16 18:57:31 by davgalle #+# #+# */
/* Updated: 2023/07/18 14:57:40 by davgalle ### ########.fr */
/* */
/* ************************************************************************** */
#include<stdio.h>
#include<string.h>
#include<unistd.h>
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (src[i] != '\0' && i < n)
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}
/*
int main(void)
{
char src[] = "eskerrik asko";
char dest[] = "ez horregatik";
ft_strncpy(dest, src, 4);
printf("%s", dest);
return (0);
}*/