-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strsub.c
executable file
·28 lines (25 loc) · 1.23 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
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_strsub.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: brobicho <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2017/12/04 03:20:00 by brobicho #+# ## ## #+# */
/* Updated: 2017/12/04 03:20:00 by brobicho ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *res;
unsigned long i;
if (!(res = malloc(len + 1)) || !s || start > ft_strlen(s))
return (NULL);
i = 0;
while (i < len && s[start])
res[i++] = s[start++];
res[i] = '\0';
return (res);
}