-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strsub.c
More file actions
35 lines (32 loc) · 1.18 KB
/
Copy pathft_strsub.c
File metadata and controls
35 lines (32 loc) · 1.18 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
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maloua-h <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/04 18:24:38 by maloua-h #+# #+# */
/* Updated: 2019/02/04 16:42:34 by maloua-h ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *res;
size_t i;
i = 0;
res = ft_strnew(len);
if (!res)
return (NULL);
if (!s)
return (NULL);
while (i < len)
{
res[i] = s[start];
i++;
start++;
}
res[i] = '\0';
return (res);
}