-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strsub.c
27 lines (24 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: imarakho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/24 18:24:48 by imarakho #+# #+# */
/* Updated: 2016/12/01 19:33:01 by imarakho ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
size_t j;
char *buf;
j = 0;
if (!s || !(buf = (char *)malloc(sizeof(char) * (len + 1))))
return (NULL);
while (len--)
buf[j++] = s[start++];
buf[j] = '\0';
return (buf);
}