Questions tagged [load]
the first part of pset5, loading a dictionary into memory
414
questions
0
votes
1
answer
43
views
PSET5 - 3 conceptual questions (debug not needed)
Question 1 (hash) – is it even remotely possible to reverse engineer the hash function when given lots of output?
For example if the underlying hash function is something simple like tolower(word[0]) %...
0
votes
2
answers
17
views
Speller returning 'a' or 'A' as misspelled 500+ times
I successfully managed to make the code compile and removed all segmentation faults, but now it returns the problem as described in the title. I assume the problem is in load, as it appears to not be ...
0
votes
1
answer
28
views
Speller - Doesn't work properly
I can't seem to fix this code by myself. I'm sure the main issue is in the load function, but I've changed it many times and the best I could get is a few misspelled words. I haven't even changed the ...
0
votes
1
answer
35
views
Speller perfomance question
I've completed speller and passed all checks. But I'm still bugged about the performance. I did my best with research and running tests, but my implementation is slower by 10-20% compared to staff's ...
0
votes
1
answer
28
views
Pset5 Speller and the point of malloc
I'm having a really hard time understanding why we use malloc to get memory instead of just using the regular int n = 0; way. Typically when we want to make an int, we type int n; not int* n = malloc(...
0
votes
0
answers
37
views
Speller: Load function only reads 9 words to memory
I finished coding all functions for the pset5. However, all my tests result in the same output:
Words in Dictionary: 9
It does not matter which texts I am running. But, I cannot find my fault in the ...
0
votes
1
answer
16
views
Clang error when compiling (Pset 5)
I tried googling this but I couldn't find (or understand) much. I'm receiving the following error when I go to make dictionary:
Here is my code for the load portion:
0
votes
1
answer
78
views
Pset5 speller load
I am having an issue with my load function in pset5 speller, I really can't tell what's going on. I've gone back and rewatched the lectures and have redone my code a few times but just can't figure it ...
0
votes
1
answer
37
views
PSET5 Why Speller can't load dictionary? (included HASH function in case it's relevant)
// Load function
bool load(const char *dictionary)
{
char word[LENGTH + 1];
FILE *file = fopen("dictionary", "r");
if (file == NULL)
{
printf(&...
0
votes
1
answer
15
views
pset4 CS50 IDE broken when opened card.raw
While I was working on pset4/recover I couldn't make it work as desired, so I wanted to check the first few bytes of card.raw manually. I double-clicked the file and now my cs50 IDE never loads and ...
0
votes
1
answer
46
views
Help with check function (PSET5)
My check function is counting the right amount of words in dictionary and text, but it outputs words that are not misspelled.
Here are all the functions of the problem, the arrays are used to locate ...
0
votes
1
answer
33
views
Speller code doesn't handle apostrophes and substrings properly
this is my code: https://pastebin.com/hJfQH6Vb
Any help is appreciated.
0
votes
1
answer
44
views
problems in unload function-pset5
// Implements a dictionary's functionality
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#...
0
votes
1
answer
60
views
Problem Set 5 - Segmentation Fault
I am trying to overcome the segmentation fault on the following code, and I couldn't manage to solve the error. Segmentation fault occurs in the load() function, and after hours of debugging, I couldn'...
0
votes
1
answer
43
views
Speller skips first word in dictionary
After chasing down and eliminating memory leaks, I think I am getting close to finishing speller. So far, valgrind says no memory leaks, and the output is formatted correctly. However, when running my ...
1
vote
1
answer
59
views
PSET 5 Load Function woes
Back with more questions about my code.
1) fscanf: When using fscanf do we need to iterate through what it is writing to the buffer to check for the null signifier so we can jump in and strcpy that ...
0
votes
2
answers
89
views
PSET5 Speller Load function skips the words from the dictionary
Struggling with the load function in speller for second week now. What I found using debug50 and placing "printf" between different lines of code is that the fscanf reads every second word ...
0
votes
1
answer
29
views
Pset5 - Speller - Seg fault
I'm getting a segmentation fault when running this. Valgrind reports no errors, but a leak of 1,080 bytes at two blocks, with 5 allocs and only 3 free'd. Below is my load function and below that are ...
0
votes
2
answers
130
views
Pset5 - Speller - Valgrind error for malloc in load function
I get all test results correct except the Valgrind error as follows, does anyone know why is it so and share some insights please? thanks!
running valgrind --show-leak-kinds=all --xml=yes --xml-file=/...
0
votes
1
answer
71
views
Pset 5 speller load function and word
I'm working on my load function to obtain the "word" from dictionary and I obtain one of the next message
dictionary.c:59:28: error: use of undeclared identifier 'word'; did you mean 'load'?
...
0
votes
1
answer
71
views
PSET5/Speller - Valgrind error: conditional jump, relates to table[i] array, but I've already initialized that (or have I?)?
I posted something similar a couple of days ago but have made progress since then. Specifically I found a couple of posts answered by Cliff B indicating the problem users had was that they hadn't ...
0
votes
2
answers
61
views
Segmentation Fault on Speller's Load function
bool load(const char *dictionary)
{
FILE *dict = fopen(dictionary, "r");
if (dict == NULL)
{
return false;
}
char word[LENGTH + 1];
while (fscanf(dict, "%s&...
0
votes
1
answer
41
views
Pset5 Speller Valgrind error trouble
Baby programmer over here. Before moving on to the (check) function, I wanted to make sure the (load) function was correct.
After performing Valgrind, I received the following errors. Up to this point,...
0
votes
1
answer
52
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
1
answer
38
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
0
answers
22
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
1
answer
23
views
My load function is licking memory
the program complies properly but when i use valgrind shows am leaking memory when I open the file in the FILE *file = fopen(dictionary, "r");
bool load(const char *dictionary)
{
// TODO
...
0
votes
0
answers
20
views
Pset5: Problem with loading multiple words with the same hash number
I am having problems with loading multiple words with the same hash code. The hash function I chose, from what I can understand, takes the ascii codes of all of the words in the dictionary, and ...
0
votes
1
answer
28
views
cs50 Speller Question
I am currently working on the load function in Speller. When I run it with a file, most of the words are mispelled, leading me to believe that initializing my list works correctly, until it adds ...
0
votes
1
answer
75
views
Speller pset 5: Valgrind gives me error
I am doing pset 5 speller and It seems to be okey less valgrind check.
Valgrind HELP50 gives me these errors
==22585== Use of uninitialised value of size 8
==22585== at 0x40110B: hash (dictionary.c:...
0
votes
1
answer
126
views
PSET 5 Speller - Unload leaking a ton of memory
I've been trying to read other questions on stack exchange about it and do research on it but I really couldn't find a solution for my unload problem. It doesn't seem to unload much. I tried a lot of ...
0
votes
0
answers
52
views
PSET5 dictionaries won't load
I cannot get my dictionaries to load and cannot figure out why. Here is my load function:
// Loads dictionary into memory, returning true if successful else false
bool load(const char *dictionary)
{
...
0
votes
1
answer
137
views
Pset5: Speller. incorrect counting of mispelled words
I've been working on this code for the last two weeks... I load the correct # of words into the dictionary, but I get an incorrect number for misspelled words. I believe its an issue either with my ...
0
votes
1
answer
87
views
Speller week 5 Segmentation fault
I can't understand where and what my error is
I think it's because of "load", but I can't fix it
it returns an error when checking
:) dictionary.c, dictionary.h, and Makefile exist
:) ...
0
votes
3
answers
370
views
PSET 5 Hash help
I started my load function without looking at any reference code (first time starting a pset this way) to give me an idea on how to implement my own version. I was mostly confident until I reached the ...
0
votes
1
answer
50
views
Pset5 segmentation fault due to sprintf
// Loads dictionary into memory, returning true if successful else false
bool load(const char *dictionary)
{
int i;
for (i = 0; i < 5382; i++)
{
table[i] = NULL;
}
int ...
0
votes
2
answers
142
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
1
answer
117
views
pset5 speller, passes all Check50 requirements except the last one (Valgrind)
My code is now working fine but misses out on fully completing Check50 because of the last requirement. Running ~/pset5/speller/ $ help50 valgrind ./speller texts/cat.txt, it returns:
==6259== ...
0
votes
1
answer
46
views
PSet5 Speller, Load Function, help50 Valgrind returns "==2480== Conditional jump or move depends on uninitialised value(s)" at the strcpy line
I've been working on Speller for a while now, but I've been stuck on this same problem. When testing my code by running ./speller texts/ANYOFTHETEXTS, it says I load 143092 words, but it also always ...
0
votes
1
answer
59
views
Speller.c doesn't work
I've spent pretty much time trying to solve a speller and got really stuck, don't know what's wrong with my code. It compiles but check50 says it's totally incorrect. I would be grateful if you could ...
0
votes
1
answer
38
views
PSET 5 segmentation fault on checker
I figured out that the problem is the checker. The output of this code is a segmentation fault. I think I followed everything on the walkthrough. Here is the result that I got: the result of the code. ...
0
votes
1
answer
362
views
CS50 Speller Load function
I looked through my load function with debug50 and realised that each time the loop is iterated, the pointer temp always gets assigned the same value despite freeing it, how do Igo about resolving ...
0
votes
2
answers
45
views
PSET5 - Valgrind error - no enough bytes are being freed
I've been on this pset for some time now and everythin seems to be working except that there are some memory leaks and I really can't understand why. I've checked a lot of other people's codes but I ...
0
votes
1
answer
54
views
Speller Load doesn't see certain words
My load function sometimes overlooks certain words in the dictionary. For example it jumps over the word "nodes" instead of loading it into the hash table.
bool load(const char *dictionary)
{
// ...
0
votes
2
answers
66
views
load function in speller not working properly not seem to figure out the correct way to link hastable?
Implements a dictionary's functionality
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <strings.h>
#...
3
votes
1
answer
1k
views
Help with PSet 5 2020 - Speller - Check & Unload Functions (EDIT: logic error in Load Function)
EDIT: Fixed the problem. The issue was not with the check or unload function but with the load function which had a small but very significant logic error. Figured it out with some great help from a ...
0
votes
1
answer
37
views
speller giving error on valgrind, using 4 bytes of memory that isn't yours...indexing an array out of bounds
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;...
0
votes
1
answer
171
views
PSET5 - Speller - Doesn't display anything past MISSPELLED WORDS
I've been debugging for quite a while now and can't seem to figure out the solution to this problem. When I use the large or small dictionary on any of the texts, the program becomes stuck at ...
0
votes
0
answers
39
views
pset5 speller issue
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include "dictionary.h"
#include "string.h"
#include <cs50.h>
#include <strings.h>
typedef struct node
{
...
0
votes
0
answers
32
views
Pset5 - Segmentation fault (Load function) - Using a for loop to make all elements of table[i] = NULL
The following is my load function and I am having a segmentation fault when I run the executable code by typing for example when I type
./speller texts/aca.txt
When I run debug50, it is pointing to ...