-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_countwords.c
38 lines (35 loc) · 1.12 KB
/
ft_countwords.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
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_countwords.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vinguyen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/11 05:36:54 by vinguyen #+# #+# */
/* Updated: 2019/10/11 05:36:58 by vinguyen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_countwords(char *s, char dl)
{
int count;
int start;
count = 0;
start = 0;
while (s && *s)
{
if (*s == dl)
{
s++;
}
else
{
count++;
while (*s && *s != dl)
{
s++;
}
}
}
return (count);
}