-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcut.c
28 lines (24 loc) · 1.17 KB
/
ft_strcut.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcut.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dbrophy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/19 14:05:49 by dbrophy #+# #+# */
/* Updated: 2020/02/19 14:05:49 by dbrophy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** ft_strcut returns a copy of the string s up to character c
** If character c is not found then a copy of the whole string is returned
*/
char *ft_strcut(const char *s, char c)
{
int i;
i = ft_strchri(s, c);
if (i == -1)
return (ft_strdup(s));
return (ft_strsub(s, 0, i));
}