-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strndup.c
25 lines (22 loc) · 1.08 KB
/
ft_strndup.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gfoote <gfoote@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/08 16:16:33 by gfoote #+# #+# */
/* Updated: 2019/04/08 18:22:48 by gfoote ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s, size_t n)
{
char *result;
result = ft_strnew(n);
if (!result)
return (NULL);
result = ft_strncpy(result, s, n);
result[n] = '\0';
return (result);
}