I think the problem with is the load() function, here is my code:
bool load(const char *dictionary)
{
char *s = malloc(LENGTH + 1);
FILE *f = fopen(dictionary, "r");
if (f == NULL)
{
return false;
}
while (fscanf(f, "%s", s) != EOF)
{
node *n = malloc(sizeof(node));
if (n == NULL)
{
unload();
return false;
}
strcpy(n -> word, s);
int x = hash(n -> word);
n -> next = table[x];
table[x] = n;
fclose (f);
}
free(s);
return true;
}
help50 is asking me to look at this line - while (fscanf(f, "%s", s) != EOF)
This is the complete message - Looks like you're trying to access 4 bytes of memory that isn't yours? Did you try to index into an array beyond its bounds? I have no idea what it means by the memory doesn't 'belongs' to me! I have used malloc() to assign memory to it! Can someone please explain what went wrong??