-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strsub.c
27 lines (24 loc) · 1.13 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: mfebvay <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/11/27 18:57:48 by mfebvay #+# #+# */
/* Updated: 2015/01/22 06:25:35 by mfebvay ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *str;
size_t i;
if (!(str = (char *)malloc((len + 1) * sizeof(char))))
return (NULL);
i = -1;
while (++i < len)
str[i] = s[start + i];
str[i] = '\0';
return (str);
}