-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strncpy.c
More file actions
41 lines (37 loc) · 1.56 KB
/
ft_strncpy.c
File metadata and controls
41 lines (37 loc) · 1.56 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bnoufel <bnoufel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 16:09:13 by bnoufel #+# #+# */
/* Updated: 2020/02/08 19:49:38 by bnoufel ### ########.fr */
/* */
/* ************************************************************************** */
#include "mem.h"
#include "str.h"
/*
** @param char *dst
** @param char *src
** @param size_t len
** The ft_strncpy functions copy at most len characters from src into dst.
** If src is less than len characters long, the remainder of dst is filled.
** with `\0' characters. Otherwise, dst is not terminated.
** The source and destination strings should not overlap,
** as the behavior is undefined.
************************* RETURN VALUES **********************************
** The ft_strncpy functions return dst.
*/
char *ft_strncpy(char *dst, const char *src, size_t len)
{
size_t i;
i = ft_strlen(src);
ft_memcpy(dst, src, len);
while (i < len)
{
dst[i] = '\0';
i++;
}
return (dst);
}