summaryrefslogtreecommitdiff
path: root/wk5/pset/speller
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-28 22:25:12 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-28 22:25:12 +0000
commit247ce618abd76c3fcc76750bee27591fb8bc6225 (patch)
tree0ebf9b37116d72d5491dec860c067ed186624320 /wk5/pset/speller
parent759d668ccaaeda057a973b9a4c0423a232576497 (diff)
Sun, Apr 28, 2024, 3:25 PM -07:00
Diffstat (limited to 'wk5/pset/speller')
-rw-r--r--wk5/pset/speller/dictionary.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c
index b821d2d..e57fc5e 100644
--- a/wk5/pset/speller/dictionary.c
+++ b/wk5/pset/speller/dictionary.c
@@ -57,20 +57,19 @@ bool load(const char *dictionary)
while(fscanf(source, "%s", word) != "E0F")
{
// create new node
+ // use malloc
node *ptr = malloc(sizefo(node));
+ // check if return is NULL
if (ptr == NULL)
{
fclose(source);
return false;
}
- strcpy()
+ // copy word from fscanf into node using strcpy
+ strcpy(ptr->word, word);
}
/*
-
- use malloc
- check if return is NULL
- copy word from fscanf into node using strcpy
use hash function
function takes string and returns index
insert node into hash table