From 247ce618abd76c3fcc76750bee27591fb8bc6225 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:25:12 +0000 Subject: Sun, Apr 28, 2024, 3:25 PM -07:00 --- wk5/pset/speller/dictionary.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'wk5/pset/speller') 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 -- cgit v1.2.3