-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strsub.c
29 lines (26 loc) · 1.2 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: thakala <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/17 12:05:10 by thakala #+# #+# */
/* Updated: 2021/12/05 13:51:05 by thakala ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
#include <stdlib.h>
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *substr;
size_t zu_start;
substr = (char *)malloc(sizeof(char) * (len + 1));
if (!substr)
return (NULL);
zu_start = start + len;
substr[len] = '\0';
while (--len + 1)
substr[len] = s[--zu_start];
return (substr);
}