Questions tagged [speller]

speller.c is one of the files that make up Problem Set 5, but it is already written by CS50 Staff and you may not alter it! Instead, you must implement your solution by altering three other component files: dictionary.c, dictionary.h, and Makefile.

Filter by
Sorted by
Tagged with
0
votes
2answers
20 views

Problem freeing memory in Speller hash function

I have a problem to free the memory for the variable lowercaseword, I try to do it above the return statement with free(lowercaseword), but then the program stops working and I get errors on check50. ...
0
votes
1answer
53 views

pset5 valgrind tests failed

I'm very close to completing pset5; all smiley faces except the Valgrind memory leak. I'm hoping someone can help find the problem. I am only leaking 112 bytes and have tried to fix the issue by ...
0
votes
1answer
132 views

Pset5 Unload will not compile

I am still stuck on pset5 speller.c. I am trying to implement unload via tries. I have tried several different codes which were not giving the correct output, but the last one I did could not even ...
0
votes
1answer
49 views

Pset4 Speller (valgrind)

// Unloads dictionary from memory, returning true if successful else false bool unload(void) { // TODO node *ptr; while (root) { int last_child; node *tmp; ptr =...
0
votes
1answer
762 views

CS50 Speller Pset5 - Comparing succeeds, Check50 fails and Valgrind succeeds

Comparing output with ~cs50/pset5/speller texts/austinpowers.txt returns successfully and valgrind works. I don't know why Check50 gives an error. I would appreciate some help please. Check50 NOW ...
0
votes
1answer
33 views

Struggling with PSET5 Speller valgrind problems (& possibly more)

I've been working on PSET5 for weeks now on & off and I'm becoming really frustrated. I think I'm lacking some understanding of the malloc/free relationship, I'm not sure. Here's all of my code. ...
0
votes
1answer
231 views

How do I load words in speller that are mixed letters and numbers?

I'm struggling with pset 6 (quite difficult logical and implementation wise, but I like this level of difficulty and this challenge). I'm implementing load and I just found out that I'm 34 words off ...
0
votes
1answer
69 views

(PSET 5) Test for case-insensitivity fails

I used strcasecmp for comparing the words case-insensitively. However, check50 showed that I failed the test for case-insensitivity. I believe that my programme treated foO, fOo, Foo, fOO, FoO, FOo ...
0
votes
1answer
22 views

(Speller) Search Function returns each word given as false, And when i run Small Dictionary gives me Segmentation Fault

// Implements a dictionary's functionality #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <ctype.h> #...
0
votes
1answer
364 views

How can I debug my load() function in Speller?

So I have code that I feel as though should be working, but I'm having trouble checking my work. I wrote a function that I think loops through my table, but it only displays half of the data seemingly....
0
votes
1answer
94 views

Speller thoroughly modified yet still fails tests pset5

I have put many controls into the code, simplified the hash function, used gdb extensively, all which suggest the code works yet it still fails the tests, especially words like Still, Home, Video, ...
0
votes
1answer
42 views

PSET 5 My hash table doesn't seem to be storing correctly

When I load the dictionary, I add the words to the hash table, by calling the hash function to calculate the bucket ID, then add hash function to actually insert it into the list. Inside the addhash ...
0
votes
1answer
42 views

How can I tell if I'm analyzing my Speller load() results correctly

As far as I can tell the code I have seems correct, though when I try to print out what my table contains, I get repeats of the same value. I can't tell if I am printing the data from my hashtable ...
0
votes
1answer
106 views

PSET 5 Speller Failing free memory of errors final check

So i am so close to finally completing this present and i still have some final errors to go through. Valgrind is saying that it is still leaking memory for some reason and i cant find the reason why. ...
0
votes
1answer
322 views

I'm really having a hard time with speller! Gives me a seg. fault. Please, help!

This is my code for load and valgrind points at line 127 as the reason for the seg. falut. Please, can someone point out to me why. Thanks.`/** *Loads dictionary into memory. Returns true if ...
0
votes
1answer
90 views

Logic Error in speller.c - Can't open text file and also have doubts about load() and check()

I wrote check() and then I tried to test speller with dictionary/small and a text file I'd written myself, but the text file couldn't be opened. Is there a problem with the way I implemented load() ...
0
votes
2answers
39 views

strcpy not working with struct items

bool load(const char *dictionary) { char splitStrings[9999][45]; FILE* dict = fopen(dictionary, "r"); node* item = table[0]; int i = 0; for (i = 0; fscanf(dict, "%...
0
votes
1answer
55 views

cs50 pset4 speller trie word too long “index 46 out of bounds for type 'char [46]'”. Isn't that handled by the code already written?

My code is giving all the right answers (lalaland.txt), but valgrind says: ==9947== dictionary.c:69:25: runtime error: index 46 out of bounds for type 'char [46]' (and I printf the problem - too ...
0
votes
1answer
28 views

“Could not unload” error in pset4 speller

I am solving speller pset5. In check50 my code is wrong. Don't know why. dictionary.c:// Implements a dictionary's functionality #include <stdbool.h> #include <strings.h> #include <...
0
votes
2answers
52 views

Valgrind errors: “invalid read of size 8” and “…uninitialised value” (pset5, speller)

I have basically finished the code, no memory leaking and tests work out fine. However, Valgrind is not happy: Conditional jump or move depends on uninitialised value(s): line 141 This is one of the ...
0
votes
0answers
14 views

PSet 5 Speller - Valgrind Segmentation Fault

I keep getting a hit on valgrind. It says to check line 99 but I know I free(cursor) before the end of the block :-( my entire code
0
votes
1answer
37 views

Word array sometimes filled with weird values - Speller

My code looks like this: (ignore the comments; they're old) // Implements a dictionary's functionality #include <stdbool.h> #include <string.h> #include "dictionary.h" #include &...
0
votes
1answer
12 views

Memory Leak Even Though Memory Freed - Speller

The error specifically refers to line 36, which is when memory is allocated to the node pointer "temporary" in the check function. At the end of the function, I am still freeing the code, ...
0
votes
1answer
13 views

PSet 5 Speller - Expected Identifier

Been stuck on Speller for 2 days and could really please use some help. My initial idea is just to create an array of linked lists with 26 buckets (N = 26) and very simply hash the words by only the ...
0
votes
1answer
38 views

All words are returned misspelled

I'm running this program on a small dictionary and a small text sample. I think that loading the dictionary is working correctly. But how can I know for sure? When I implement the load and check ...
0
votes
0answers
14 views

Speller - Compiles but Doesn't Hit Criteria for Completion

I've been having a lot of trouble with Speller. This compiles but almost all the criteria are red, for example it doesn't basic words properly, doesn't handle 1 char words or long words, etc. I'm not ...
0
votes
1answer
15 views

The strcsecmp() function is not working as expected

I am currently trying to solve pset5, speller. I managed to write every funtion correctly except of the check() function. This is the check() function I wrote so far: // Returns true if word is in ...
0
votes
1answer
29 views

CS50 Speller Not Free of Memory Errors

When I run check50 on my code, valgrind says: Conditional jump or move depends on uninitialised value(s): (file: dictionary.c, line: 34) 112 bytes in 2 blocks are still reachable in loss record 1 of 1:...
0
votes
1answer
26 views

speller - unload returns false …?

unload returns false and i am not sure why.... when i run Valgrind i get this: HEAP SUMMARY: ==7885== in use at exit: 608 bytes in 2 blocks ==7885== total heap usage: 143,096 allocs, 143,094 ...
0
votes
1answer
208 views

Need help: pset5 “Speller”

I am having a strange issue with the pset5. When I debug the file, it works fine, but when I check it through Check50, it throws several frowns at me. Need suggestions. Here is my code: #include <...
0
votes
1answer
23 views

Hash Function in Speller - Use of Undeclared Identifier Error

I'm stuck on the speller assignment but it feels like the smallest thing to be stuck on....in my hash function I keep getting "use of undeclared identifier" for n and i. Usually if this ...
0
votes
1answer
44 views

PSET5 Speller using trie memory leak

Could somebody help me identify the cause of the memory leak shown by Valgrind? Check50 says that there are no leaks, for some reason. Here is my code for dictionary.c // Implements a dictionary's ...
0
votes
1answer
24 views

Pset5: check returns hashtable pointers as NULL despite hashtable values printed correctly in load

My check function returns all hashtable indexes as NULL (I printed a known index of 124 and still returns NULL), despite all indexes printed correctly in load. I am not sure where exactly the problem ...
0
votes
1answer
28 views

pset 5 Seg Fault

I just wrote this code and in terms of ideas(of data structures), I really think it makes sense but it gets Segmentation fault. I am not sure about the unload function. Can you search for seg fault ...
2
votes
2answers
89 views

2019 PSET4 SPELLER, I have no clue why it isn't working, I'm sure size and unload function is right, but unsure about load and check

// Implements a dictionary's functionality #include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #...
0
votes
1answer
29 views

cs50 speller code complies and run also successfully. but it not qualifying for big board

:) dictionary.c and dictionary.h exist :) speller compiles :( qualifies for Big Board expected exit code 0, not 139 :| passes benchmarking can't check until a frown turns upside down how to fix this *...
0
votes
1answer
19 views

Errors with Valgrind on Speller (Still Reachable) - PSET5

I am almost done with speller but when I pass it through valgrind, it says there are some mistakes. More specifically, it says a bunch of bytes are still reachable. I don't know whether my problem is ...
0
votes
1answer
53 views

Segmentation fault - Pset4 Speller

My code has a segmentation fault and always prints this out: MISSPELLED WORDS dictionary.c:111:19: runtime error: member access within null pointer of type 'node' (aka 'struct node') Segmentation ...
0
votes
1answer
23 views

When declaring an array of pointers that will be a hash table, do you have to set all the elements of the array to NULL?

In the distribution code for Speller in pset5, they include this line in dictionary.c // Hash table node *table[N]; Should I set every element in the array to NULL, because they are pointers? (the ...
0
votes
1answer
76 views

Valgrind uninitialized values pset5

This is my solution for pset5's speller problem, which uploads a dictionary with a hash table and checks an inputed text to find misspelled words. My code works fine when I run, but valgrind says "...
1
vote
1answer
76 views

Speller (PSET5) has output that is exactly the same as the staff's solution, but check50 returns many errors. What's happening?

My speller program (part of pset5) works well and the output exactly matches that of the staff's solution. However, when I run my program through check50, I still get several errors per their script: ...
0
votes
1answer
35 views

Why is fscanf giving me an undefinedbehavioursanitiser error?

my code looks like int main(void) { char word[45]; FILE *dictionary = fopen("dictionary/small", "r"); fscanf(dictionary, "%10s", word); fclose(dictionary); } Inside of ...
0
votes
1answer
20 views

pset5 speller check function: cursor pointer keeps being NULL

I finished writing the code and tried to run the program, but it returned all words as misspelled. When I ran debug50 on the check function, it shows that the cursor pointer does not take the value of ...
0
votes
1answer
247 views

CS50 pset 4 speller - qualifies for bigboard

My code qualifies with check50, valgrind and style 50. But when I want to submit it to big board it says "timed out while waiting for program to exit" Here's my dictionary.c - // Implements a ...
0
votes
1answer
40 views

Pset5 Speller dictionary entries getting overwritten

I'm having problems with pset5 speller where the words I load into my dictionary hash table are getting overwritten. So for example if I load "Ashley", "Britney" and "Charlie" into my dictionary, all ...
0
votes
1answer
18 views

Trying to fix a segfault in unload , pset5, speller

So when I originally wrote my code for the dictionary.c, I forgot to create the header nodes for each 'bucket' in the hash table. It ran well when every first node of each linked list had a letter, ...
0
votes
1answer
67 views

Check function Segmentation

I am struggling to find the problem in my check function. I have a segmentation fault that it's position varies every time I alter my code a bit. bool check(const char *word) { int index = hash(...
0
votes
0answers
16 views

trouble loading dictionary

my load function seems to only load two words and all words are coming back misspelled. I don't know if the problem is with my load function or the hash function. I've gone over the load function ...
0
votes
1answer
26 views

Why do I get a sanitiser error when creating this node loop?

This is the loop node *root; root = malloc(sizeof(node)); for(node *ptr = root; counter < length_of_input ; ptr = ptr-> a_node) { if(counter != 0) { ...
0
votes
1answer
73 views

Getting a segmentation fault when i try to run pset5 speller and i'm not sure what's the problem. Appreciate it if someone can explain. thanks!

// Implements a dictionary's functionality include include "dictionary.h" include include include include // Represents a node in a hash table typedef struct node { char word[LENGTH + ...

1
2 3 4 5
16