2
votes
Accepted
typedef struct declarations?
I found Rob's explanation in this video (starting around 6:40) helpful.
He says:
we need the identifier next to struct if the definition of the struct is recursive. .... This struct is recursive, ...
1
vote
Accepted
Week 5 Walkthroughs
Place the file named spl.jar (from pset4 files) in the same directory as your executable!
1
vote
Accepted
valgrind free and leaks
Pretty much. In very specific environments Application allocated memory may not be fully freed when the application exits. But it's safe to say that in any regular OS'es (including the one you're ...
1
vote
Accepted
speller giving error on valgrind, using 4 bytes of memory that isn't yours...indexing an array out of bounds
Closing the dictionary file after the first word is processed is indicated.
From man fclose (emphasis added):
Return Value
Upon successful completion 0 is returned. Otherwise, EOF
is returned and ...
1
vote
Replacement of string with char* in any general case
A couple of things about your program, the variable c is a pointer to a string, but it has no memory assigned, if you want to use c as it is, you must use the malloc function.
The variable c is not ...
1
vote
Accepted
Week 5 Speller Check function
The check() function as written simply doesn't work. The word is copied to local var word in check(), but the contents are never used or copied. Most of the work is being done on another local var ...
1
vote
Accepted
PSET5 speller: all words listed as mispelled and check50 gives substrings a sad face
The
hashtable[i] = malloc(sizeof(node));
hashtable[i]-> next = NULL;
makes no sense to me. Why create a node if you don't have content for it yet?
The hashtable[i] = NULL; also ...
1
vote
Accepted
Cs50 speller load trie failed implementation
No sure where seg fault comes from, but it basically doesn't matter as you do something completely bizarre.
Let's look what you are doing:
read the whole word from dictionary. Let it be "foo".
...
1
vote
Accepted
Week 5 - Speller. Instance remaining as NULL after setting inside function
Function parameters in C are usually passed by value, creating a variable that's initialised to the passed value. That means your assignment to tree changes the variable tree in addWordToTree, but ...
Only top scored, non community-wiki answers of a minimum length are eligible