-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_restrsub.c
35 lines (32 loc) · 1.13 KB
/
ft_restrsub.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_restrsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbecker <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/12 19:57:18 by sbecker #+# #+# */
/* Updated: 2019/03/12 20:01:08 by sbecker ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_restrsub(char *s, int start, int len)
{
char *a;
int i;
i = 0;
if (!s)
return (0);
if ((a = (char*)malloc(len + 1)))
{
while (i < len)
{
a[i] = s[start];
start++;
i++;
}
a[i] = '\0';
}
free(s);
return (a);
}