-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_countwords_space.c
32 lines (29 loc) · 1.22 KB
/
ft_countwords_space.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_space.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nristorc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/10 14:47:22 by nristorc #+# #+# */
/* Updated: 2018/01/11 16:47:27 by nristorc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_countwords_space(char *str)
{
int count;
count = 0;
while (*str)
{
while (*str && (*str == ' ' || *str == '\t' || *str == '\n'))
str++;
if (*str && *str != ' ' && *str != '\n' && *str != '\t')
{
count++;
while (*str && (*str == ' ' || *str == '\t' || *str == '\n'))
str++;
}
}
return (count);
}