-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strsub.c
29 lines (26 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tlevaufr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/14 14:42:17 by tlevaufr #+# #+# */
/* Updated: 2017/12/05 00:44:15 by tlevaufr ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
size_t t;
char *str;
t = 0;
if (s == NULL)
return (NULL);
if (!(str = ft_strnew(len)))
return (NULL);
while (t < len)
str[t++] = s[start++];
str[t] = '\0';
return (str);
}