-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncpy.c
executable file
·34 lines (31 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akalombo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/18 11:08:11 by akalombo #+# #+# */
/* Updated: 2019/06/24 10:00:49 by akalombo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dest, const char *src, size_t n)
{
size_t i;
size_t a;
i = 0;
while (src[i] != '\0' && (i < n))
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
a = ft_strlen(dest) - i;
dest[i + a] = '\0';
return (dest);
}