aboutsummaryrefslogtreecommitdiff
path: root/6.3/main.c
diff options
context:
space:
mode:
Diffstat (limited to '6.3/main.c')
-rw-r--r--6.3/main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/6.3/main.c b/6.3/main.c
new file mode 100644
index 0000000..cd52cec
--- /dev/null
+++ b/6.3/main.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include "word.h"
+#include "tree.h"
+
+#define MAXWORD 100
+#define ARR_SIZE(X) (sizeof(X)/sizeof(X[0]))
+
+const char *noise[] = {
+ "the",
+ "and"
+};
+
+int isnoise(char *word);
+
+int main(void)
+{
+ char word[MAXWORD];
+ struct tnode *root;
+ int line = 0;
+
+ root = NULL;
+ while (getword(word, MAXWORD) != EOF)
+ if (isalpha(word[0]) && !isnoise(word))
+ root = addtree(root, word, line);
+ else if(word[0] == '\n')
+ ++line;
+
+ tprint(root);
+ tfree(root);
+
+ return 0;
+}
+
+int isnoise(char *word)
+{
+ size_t i;
+
+ for(i = 0; i < ARR_SIZE(noise); ++i)
+ if (!strcmp(word, noise[i]))
+ return 1;
+
+ return 0;
+}