diff options
author | sinanmohd <sinan@firemail.cc> | 2023-05-03 16:21:54 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-05-07 15:21:39 +0530 |
commit | 329fada630517195a472da703d19d7eced62c5a8 (patch) | |
tree | 8ef85bac36a3777e67fc10613ef9eaee8e46c59b /6.2/main.c | |
parent | 16c2c412f3062924ad7869068730b2c56afbcff8 (diff) |
6.2: initial commit
this version keeps the word count
Diffstat (limited to '6.2/main.c')
-rw-r--r-- | 6.2/main.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/6.2/main.c b/6.2/main.c new file mode 100644 index 0000000..57b562a --- /dev/null +++ b/6.2/main.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include "word.h" +#include "tree.h" + +#define MAXWORD 100 +#define DEFLEN 6 + +int main(int argc, char *argv[]) +{ + struct tnode *root; + char word[MAXWORD]; + int bar; + + bar = (--argc && (**++argv == '-')) ? atoi(argv[0]+1) : DEFLEN; + root = NULL; + while (getword(word, MAXWORD) != EOF) + if ((isalpha(word[0]) || (word[0] == '#' && isalpha(word[1]))) && + strlen(word) > (size_t) bar) + root = naddtree(root, word, bar, NO); + + ntreeprint(root); + treefree(root); + + return 0; +} |