ft_count_words
This commit is contained in:
parent
3e469787f9
commit
367077438c
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
obj/
|
||||
*.a
|
||||
*.o
|
||||
27
src/string/ft_count_words.c
Normal file
27
src/string/ft_count_words.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: o_ :::::: ::: */
|
||||
/* ft_count_words.c :+: / :+::+: :+: */
|
||||
/* +:+ > +:++:+ +:+ */
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
|
||||
/* +#+ +#+#+ +#++#+ +#+ \o/ */
|
||||
/* Created: 2024/12/06 13:10:36 by whaffman #+#+# #+#+# #+# #+# | */
|
||||
/* Updated: 2024/12/06 13:11:33 by whaffman ### ### ### ### / \ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_count_words(char const *s, char c)
|
||||
{
|
||||
int n;
|
||||
int i;
|
||||
|
||||
n = 0;
|
||||
i = 0;
|
||||
while (s[i])
|
||||
{
|
||||
if (s[i] != c && (s[i + 1] == c || s[i + 1] == '\0'))
|
||||
n++;
|
||||
i++;
|
||||
}
|
||||
return (n);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user