-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strsub.c
29 lines (26 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
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mrychkov <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/29 20:31:26 by mrychkov #+# #+# */
/* Updated: 2017/04/29 20:37:15 by mrychkov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
size_t i;
char *ptr;
i = 0;
if (!s)
return (NULL);
if (!(ptr = (char*)malloc(len + 1)))
return (NULL);
while (len--)
ptr[i++] = s[start++];
ptr[i] = '\0';
return (ptr);
}