aboutsummaryrefslogtreecommitdiff
path: root/6.6/main.c
diff options
context:
space:
mode:
Diffstat (limited to '6.6/main.c')
-rw-r--r--6.6/main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/6.6/main.c b/6.6/main.c
new file mode 100644
index 0000000..19a7323
--- /dev/null
+++ b/6.6/main.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include "word.h"
+#include "hash.h"
+#include "def.h"
+
+#define MAXWORD 100
+#define HASHSIZE 100
+
+struct nlist *hashtab[HASHSIZE];
+
+int main(void)
+{
+ char word[MAXWORD];
+ struct nlist *np, *temp;
+
+ while (getword(word, MAXWORD) != EOF) {
+ if (!strcmp(word, "#")) {
+ getdef(hashtab, HASHSIZE);
+ } else if (!isalpha(word[0])) {
+ printf("%s", word);
+ } else if ((np = lookup(hashtab, HASHSIZE, word)) == NULL) {
+ printf("%s", word);
+ } else {
+ ungetword(np->defn);
+ }
+ }
+
+ hashfree(hashtab, HASHSIZE);
+ return 0;
+}