-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strsub.c
37 lines (34 loc) · 1.21 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
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ctreton <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/11/21 06:37:21 by ctreton #+# #+# */
/* Updated: 2013/12/29 01:19:40 by ctreton ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *res;
size_t j;
j = 0;
if (!s)
return (NULL);
res = (char *)malloc(len * sizeof(char *));
if (res)
{
while (j < len)
{
res[j] = s[start];
j++;
start++;
}
res[j] = '\0';
return (res);
}
return (NULL);
}