-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strndup.c
More file actions
25 lines (22 loc) · 1.09 KB
/
ft_strndup.c
File metadata and controls
25 lines (22 loc) · 1.09 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahjadani <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/06 09:33:24 by ahjadani #+# #+# */
/* Updated: 2021/11/12 00:38:52 by ahjadani ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s, size_t n)
{
char *str;
str = (char *)malloc(sizeof(char) * n + 1);
if (str == NULL)
return (NULL);
str = ft_strncpy(str, s, n);
str[n] = '\0';
return (str);
}