I tried to compile "speller" to only test my load function (I'm not sure it's correct!). I haven't done the other 3 functions yet (check, size and unload). But clang says there is an error with the check function, that I did not modify. Can you please explain me this error ? Thanks in advance.
// Implements a dictionary's functionality
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>`enter code here`
#include "dictionary.h"
// Returns true if word is in dictionary else false
bool check(const char *word)
{
return false;
}
// Loads dictionary into memory, returning true if successful else false
bool load(const char *dictionary)
{
// open the dictionary file
FILE *dict_ptr = fopen(dictionary, "r");
// Creates the root
node *root = malloc(sizeof(node));
// Initialize the trav to root
node *trav = root;
// Finds a word in the file and add it to the tree
for (char c = fgetc(dict_ptr); c != EOF; c = fgetc(dict_ptr))
{
// If new line, then it's a word and reinitializes trav to root for next character
if (c == '\n')
{
trav->is_word = true;
trav = root;
}
// If the way is open, move to the next node
else if (trav->children[getIndex(c)] != NULL)
{
trav = trav->children[getIndex(c)];
}
// If it points to nothing, then creates a new node
else if (trav->children[getIndex(c)] == NULL)
{
node *newNode = malloc(sizeof(node));
trav = newNode;
}
}
return true;
}
// Returns number of words in dictionary if loaded else 0 if not yet loaded
unsigned int size(void)
{
// TODO
return 0;
}
// Unloads dictionary from memory, returning true if successful else false
bool unload(void)
{
// TODO
return false;
}
// Get the index for trie
int getIndex(char c)
{
if (c == '\'')
{
return 26;
}
else
{
return tolower(c) -'a';
}
}
Terminal:
~/workspace/pset5/speller/ $ make speller
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -c -o speller.o speller.c
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -c -o dictionary.o dictionary.c
dictionary.c:10:24: error: unused parameter 'word' [-Werror,-Wunused-parameter]
bool check(const char *word)
^
1 error generated.
make: *** [dictionary.o] Error 1