blob: 894ea4e6354e176bff56ba880ee979b86407f96c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/25 03:28:52 by cacharle #+# #+# */
/* Updated: 2020/02/14 03:43:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s1, size_t n)
{
char *clone;
if ((clone = (char*)malloc(sizeof(char) * (n + 1))) == NULL)
return (NULL);
clone[n] = '\0';
return (ft_strncpy(clone, s1, n));
}
|