-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncpy.c
36 lines (33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pix <pix@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/17 22:21:15 by stales #+# #+# */
/* Updated: 2022/04/04 03:04:24 by pix ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copy n bytes of src to dest, don't check for the length of
* dest
*
* @param dest Destination string
* @param src Source string
* @param n Size to copy
*
* @return (char *) The copied string
*/
char *ft_strncpy(char *dest, char *src, t_size n)
{
char *tmp;
tmp = dest;
n++;
while (--n && *src)
*tmp++ = *src++;
while (n--)
*tmp++ = 0;
return (dest);
}