-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strsub.c
34 lines (31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cyildiri <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/03 16:41:11 by cyildiri #+# #+# */
/* Updated: 2016/10/03 17:08:48 by cyildiri ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
unsigned int index;
int i;
char *out_str;
if (s == NULL)
return (NULL);
if (!(out_str = ft_strnew(len)))
return (NULL);
index = start;
i = 0;
while (index < start + len)
{
out_str[i] = s[index];
i++;
index++;
}
return (out_str);
}