-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strsub.c
29 lines (26 loc) · 1.16 KB
/
ft_strsub.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oadhesiv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/25 17:28:13 by oadhesiv #+# #+# */
/* Updated: 2019/06/01 22:35:22 by oadhesiv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *ret;
if (!s)
return ((void *)0);
if (len + 1 == 0)
return ((void *)0);
ret = ft_strnew(len + 1);
if (!ret)
return ((void *)0);
ft_strncpy(ret, s + start, len);
ret[len] = 0;
return (ret);
}