-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strsub.c
More file actions
29 lines (26 loc) · 1.15 KB
/
ft_strsub.c
File metadata and controls
29 lines (26 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpetsoan <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/18 11:01:22 by lpetsoan #+# #+# */
/* Updated: 2019/05/18 11:34:47 by lpetsoan ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strsub(char const *s1, unsigned int start, size_t len)
{
char *out;
int i;
i = 0;
out = (char *)malloc(len + 1);
if (!out || !len || !s1)
return (NULL);
s1 += start;
while (*s1 && len--)
out[i++] = *s1++;
out[i] = '\0';
return (out);
}