-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strncpy.c
40 lines (35 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jony <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/19 12:31:03 by mhasan #+# #+# */
/* Updated: 2019/11/04 22:03:26 by jony ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dest, char *src, size_t len)
{
size_t i;
i = 0;
while (i < len && src[i] != '\0')
{
dest[i] = src[i];
i++;
}
while (i < len)
{
dest[i] = '\0';
i++;
}
return (dest);
}
int main()
{
char src[] = "jony";
char dest[] = "mahmudul";
printf("%s\n", ft_strncpy(dest, src, 7));
return (0);
}