-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_countwords.c
32 lines (29 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_countwords.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nhennigh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/15 19:04:31 by nhennigh #+# #+# */
/* Updated: 2019/02/15 19:07:36 by nhennigh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_countwords(char const *str, char c)
{
int count;
int i;
i = 0;
count = 0;
while (str[i])
{
while (str[i] == c)
i++;
if (str[i] != c && str[i] != '\0')
count++;
while (str[i] != c && str[i] != '\0')
i++;
}
return (count);
}