-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_substr.c
More file actions
31 lines (28 loc) · 1.21 KB
/
ft_substr.c
File metadata and controls
31 lines (28 loc) · 1.21 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_substr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: egarcia- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/12 16:57:17 by egarcia- #+# #+# */
/* Updated: 2019/11/19 19:04:07 by egarcia- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_substr(char const *s, unsigned int start, size_t len)
{
char *str;
unsigned int i;
i = 0;
if (s && (int)len > -1)
{
if (!(str = malloc(((int)len + 1) * sizeof(char))))
return (NULL);
ft_bzero(str, len);
if (start <= ft_strlen(s))
ft_strlcpy(str, s + start, len + 1);
return (str);
}
return (0);
}