Please, I need your help. I have dependency issue with my code. This is check50 response on my code. I guess the problem is with my load function. After a few tweaks on the code to fix the dependency issue, the load function refused to load. I have spent much time on it but could not understand what the problem is. Below is a snippet of the code. Debug50 is of no use, as it just says "could not load dictionary/large". Do please, lend some advice.
int word_count = 0;
bool load(const char *dictionary) {
inptr = fopen ("dictionary", "r+");
if (inptr == NULL)
{
return false;
printf ("Could not open dictionary\n");
fclose(inptr);
}
node* root = calloc(1, sizeof(node));
node* pecker = root;
while (!&feof)
{
c = fgetc(inptr);
if (c == '\n')
{
pecker -> is_word = true;
pecker = root;
index = 0;
}
if (isalpha(c))
{
tolower(c);
index = (c - 'a');
}
while ((pecker -> branches[index]) == NULL)
{
pecker = calloc (1, sizeof(node));
pecker = pecker -> branches[index];
}
if (c == '\'')
{
index = 26;
if (pecker -> branches[index] == NULL)
{
pecker = calloc (1, sizeof(node));
pecker = pecker -> branches[index];
}
else if (pecker -> branches[index] != NULL)
{
pecker = pecker -> branches[index];
}
}
FILE* outptr;
outptr = fopen ("dictionary", "w+");
if (outptr != NULL)
{
fclose (outptr);
}
else if (outptr == NULL)
{
fputc (c, outptr);
}
word_count++;
if (&feof)
{
fclose(inptr);
}
}
return false;
}
check50
and that it won't finddictionary.c
), you should have created a new question. Now my twice upvoted answer is no longer related to your question, which might confuse readers.