diff options
Diffstat (limited to '6.5/main.c')
-rw-r--r-- | 6.5/main.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/6.5/main.c b/6.5/main.c new file mode 100644 index 0000000..90bc87e --- /dev/null +++ b/6.5/main.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "word.h" +#include "hash.h" + +#define MAXWORD 100 +#define HASHSIZE 100 + +struct nlist *hashtab[HASHSIZE]; + +int main(void) +{ + char word[MAXWORD]; + char *name; + + while (getword(word, MAXWORD) != EOF) { + if (!strcmp(word, "#define")) { + getword(word, MAXWORD); + name = strdup(word); + getword(word, MAXWORD); + install(hashtab, HASHSIZE, name, word); + free(name); + } else if (!strcmp(word, "#undef")) { + getword(word, MAXWORD); + undef(hashtab, HASHSIZE, word); + } + } + + phashtab(hashtab, HASHSIZE); + hashfree(hashtab, HASHSIZE); + + return 0; +} |