summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/io_count_words
diff options
context:
space:
mode:
Diffstat (limited to 'rushs/tinyprintf/io_count_words')
-rw-r--r--rushs/tinyprintf/io_count_words/count_words.c33
1 files changed, 0 insertions, 33 deletions
diff --git a/rushs/tinyprintf/io_count_words/count_words.c b/rushs/tinyprintf/io_count_words/count_words.c
deleted file mode 100644
index 8b8c9a5..0000000
--- a/rushs/tinyprintf/io_count_words/count_words.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-
-int count_words(const char *file_in)
-{
- if (file_in == NULL)
- {
- return -1;
- }
-
- FILE *f = fopen(file_in, "r");
- if (f == NULL)
- {
- return -1;
- }
-
- int word = 0;
- int count = 0;
- int c;
- while ((c = fgetc(f)) != EOF)
- {
- if ((c == ' ' || c == '\n' || c == '\t') && word == 1)
- {
- word = 0;
- }
- if (c != ' ' && c != '\n' && c != '\t' && word == 0)
- {
- word = 1;
- count++;
- }
- }
-
- return count;
-}