diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-28 22:55:17 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-28 22:55:17 +0000 |
commit | f95055912c8af3a3d98da4f7fbdffc8c3d59d2eb (patch) | |
tree | 15207299116b6838d7c95a0b69628de947c12095 /wk5/pset | |
parent | 8e5782b61c8704c059acaa9142b0eda96b173e72 (diff) |
Sun, Apr 28, 2024, 3:55 PM -07:00
Diffstat (limited to 'wk5/pset')
-rw-r--r-- | wk5/pset/speller/dictionary.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c index 002f8ab..e05f30b 100644 --- a/wk5/pset/speller/dictionary.c +++ b/wk5/pset/speller/dictionary.c @@ -18,6 +18,9 @@ const unsigned int N = 26; // Hash table node *table[N]; +// Size integer +int size = 0; + // Returns true if word is in dictionary, else false bool check(const char *word) { @@ -54,6 +57,8 @@ bool load(const char *dictionary) // check for ended file while(fscanf(source, "%s", word) != "E0F") { + // update size int + size++; // create new node // use malloc node *ptr = malloc(sizefo(node)); @@ -75,7 +80,6 @@ bool load(const char *dictionary) ptr->next = table(val)->next; } table(val)->next = *ptr; - } // Close the dictionary file @@ -86,17 +90,7 @@ bool load(const char *dictionary) // Returns number of words in dictionary if loaded, else 0 if not yet loaded unsigned int size(void) { - // TODO - char c; - int n = 0; - while (fread(&c, 1, 1, file)) - { - if (c == "\n") - { - n++; - } - } - return n; + return size; } // Unloads dictionary from memory, returning true if successful, else false |