ft_count_words

This commit is contained in:
whaffman 2024-12-06 13:14:40 +01:00
parent 3e469787f9
commit 367077438c
2 changed files with 30 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
obj/
*.a
*.o

View 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);
}