-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strsub.c
More file actions
26 lines (23 loc) · 1.12 KB
/
ft_strsub.c
File metadata and controls
26 lines (23 loc) · 1.12 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sconstab <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/30 09:17:06 by sconstab #+# #+# */
/* Updated: 2019/06/05 09:33:16 by sconstab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *ns;
if (!s || !len)
return (NULL);
if (!(ns = malloc(len + 1 * sizeof(char))))
return (NULL);
ft_strncpy(ns, s + start, len);
ns[len] = '\0';
return (ns);
}