-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strndup.c
31 lines (28 loc) · 1.15 KB
/
ft_strndup.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
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: salomon <salomon@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/05/13 17:08:22 by sbeline #+# #+# */
/* Updated: 2016/05/19 00:35:38 by salomon ### ########.fr */
/* */
/* ************************************************************************** */
#include "Includes/libft.h"
char *ft_strndup(char *s, int begin, int end)
{
char *ret;
int i;
i = 0;
if (!(ret = (char*)malloc(sizeof(char) * (end - begin) + 1)))
return(NULL);
while (begin < end)
{
ret[i] = s[begin];
i++;
begin++;
}
ret[i] = '\0';
return (ret);
}