Questions tagged [pset5]

The problem set for Week 5 will challenge you to apply what you've learned about pointers, memory management, file i/o and structs, creating more complex data structures (such as Hash Tables or Tries) and leveraging their power to write a lightning-fast spell check algorithm.

Filter by
Sorted by
Tagged with
1 vote
1 answer
356 views

pset5:(speller) Check function does not correctly identify misspelled words

/** * Implements a dictionary's functionality. */ #include <stdbool.h> #include "dictionary.h" #include<string.h> #include <stdio.h> #include <stdlib.h> #include<ctype.h&...
Benedict Florance's user avatar
0 votes
1 answer
623 views

Segmentation fault - load() function

This is my code for load() function. When I am doing "./speller text" it is showing Segmentation fault. Please help. typedef struct node { char name[LENGTH+1]; struct node* next; }node; node*...
Salil Jain's user avatar
13 votes
1 answer
3k views

check50 returns unexpected end of input

I recently finished my code for pset5 recover.c. It compiles, and runs successfully and recovers all 50 pictures. But when I try check50, it gives Checking.............................................
DivineArtist's user avatar
2 votes
2 answers
1k views

pset5 copy.c confused in fread

in copy.c i am seeing some weird code in the part of iterating the scanline and pixels. Since we are passing "inptr" to the (fread) and telling it to work just once. How does the code makes sure that ...
Milan's user avatar
  • 55
1 vote
1 answer
555 views

PSET5 Valgrind memory leak in load() and errors in many contexts

I'm trying to implement a trie for pset5. The program compiles, and appears to spit out the right output, except Valgrind seems to have a LOT of issues with it! First, there's the memory leak, which ...
Connie's user avatar
  • 13
10 votes
1 answer
4k views

How to Update bfSize in resize?

In resize problem, we have to update the headers of image. Which attributes should be updated and how do i update bfSize attribute?
HKH's user avatar
  • 150
4 votes
1 answer
3k views

What data structure do you use to store the buffer in recover?

What data structure do I use to store the 512B blocks in a buffer? Thinking about an array or ints? Or am I completely off?
Jesse's user avatar
  • 157
3 votes
1 answer
5k views

Cannot use make: "Nothing to be done for whodunit.c"

For pset5 I did as suggested and copied copy.c to a new file named whodunit.c. I've left everything the same but hopefully changed the red pixel values. When I go to compile using make I get this ...
Anna Burck's user avatar
2 votes
2 answers
6k views

pset5 speller.c check

Hi I'm tackling CS50's pset5. I am trying to implement speller and I got stuck on check part. I implemented load via hashtables and whole dictionary loads up correctly,when I'm using smaller text ...
Nedeljko Zekonja's user avatar
2 votes
1 answer
333 views

Pset5 Speller Valgrind error

I got Pset5 Speller to work correctly but I am getting a Valgrind error as follows 568 bytes in 1 blocks are still reachable in loss record 1 of 1: (file: dictionary.c, line: 108) for all the words. ...
noob's user avatar
  • 23
1 vote
2 answers
7k views

PSET5 Speller hash function

I have been working on the speller problem in pset5 for a while now, and I am not able to figure out the problem in my hash function: unsigned int hash(const char* word) { int M = 1000000001; ...
Shrey Tripathi's user avatar
1 vote
1 answer
648 views

Recover creates the pictures, able to view them, but listed as jpg? in ls and check50 fails

I checked the boards and couldn't find if anyone else had the same issue. For some reason, Recover runs 'seemingly' correctly when I ask it to and I see the pictures in the folder from "000.jpg" to "...
user81's user avatar
  • 53
0 votes
1 answer
167 views

CS50 PSET5 Memory Leak

I have spent more than 30 hours on this problem set and I am still struggling. At first, my program compiled but did not run, due to a segmentation fault. I finally fixed it and everything works fine, ...
Alex Chan's user avatar
  • 121
0 votes
1 answer
25 views

Everything is correct in my Check50 but in program I have other ERRORS - PSET05 Speller

I hope you're doing well and I also hope you might help me. When I run my CHECK50 in my speller program. Everything is correct all green, but when I run my program or valgrind I have some errors. And ...
AlvaroAndLukeTheCoder's user avatar
0 votes
1 answer
82 views

Load code pset5, speller.c. Segmentation error

bool load(const char *dictionary) { FILE *dic=fopen(dictionary, "r"); node *hashtable[26]; int num=0; char word[LENGTH+1]; while(fscanf(dic,"%s", word)!=EOF) { node *new_node=malloc(sizeof(node)...
Vaish MK's user avatar
  • 167
0 votes
1 answer
94 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 ...
cormacl's user avatar
  • 48
9 votes
1 answer
3k views

Surprise with GDB way of reading bfType BMP headers

Why if i check with the xxd an image eg. small.bmp the bfType is 0x424d and when you run copy in GDB the value of bf.bfType is 19778 and the program "copy" in line 55 check with 0x4d42. Is it reading ...
dizcola's user avatar
  • 111
6 votes
1 answer
103k views

How to fix the "conditional jump or move depends on uninitialized value" valgrind error?

Need help again. I've got my linked list working. It copies a list of words from a file into a linked list. Now I want to make a hash table so that all words starting with the letter 'A' go into a ...
jzz's user avatar
  • 65
5 votes
2 answers
12k views

Conditional jump or move depends on uninitialised value(s)

I just finish debugging my code for pset5 dictionary.c, It's working correctly, It passed check50 too. Now the problem I am encountering is in valgrind my heap is all freed, But wherever in ...
Vipin kumar's user avatar
5 votes
1 answer
981 views

Pset5: Misunderstanding tries and method to assign letter to an array inside a struct

Before posting, I've searched a lot here and there on the Internet to find the answers to my questions myself and I did code something that eventually works. My issue is that I've re-rewrote some ...
DFATPUNK's user avatar
  • 155
2 votes
1 answer
377 views

CS50 PSET5 Memory Leak (updated)

I had posted a question here two days ago regarding memory leak in problem set 5 and haven't had it resolved yet. Please refer to my question, available here: CS50 PSET5 Memory Leak (please note that ...
Alex Chan's user avatar
  • 121
2 votes
1 answer
122 views

How do I make dictionary.c compile with strings.h?

There seems to be a useful function -- strcasecmp -- in the strings.h library (notably different from string.h). However, when I try to amend this to my header information (e.g., #include <strings....
Richard's user avatar
  • 166
1 vote
1 answer
284 views

check50 has 2 TODO's in red for resize.c

When I run my implementation of resize.c in check50, there are two "TODO's" in red at the bottom of some sections. Does anyone know what this means? (My programs output is identical to the staff's ...
Mike Stache's user avatar
1 vote
1 answer
328 views

Unload function double free or corruption

so I've been battling through the fifth pset and this is where I can not find a proper way to continue. When I try to run it, it always aborts and gives this error: * Error in `./speller': double ...
Martin Wzatek's user avatar
1 vote
1 answer
2k views

resize: having header problems

My program compiles and everything, but when I try to open up the image it says the image has "bogus header files". I'm not sure what I'm doing wrong. Here's some of my code: // read infile's ...
dottified's user avatar
1 vote
1 answer
2k views

Speller.c appears to be working but is case sensitive (can't recognize capitol letters)

I'm getting my spell checker to load and check. It appears to work (as far as I've tested thus far) except for I can't get it to be case insensitive. I've tried a couple of approaches, but in both ...
Brandon Terry's user avatar
1 vote
1 answer
231 views

pset5 load function segfault do not show in gdb

I cannot figure what's wrong with the code, it gives me a segfault, but runs in valgrind and in gdb. So far, i only wrote the load function, so anything else is still empty. #include <stdbool....
user10187's user avatar
1 vote
2 answers
287 views

Problem in my unload function (double free or corruption)

so I have been straggling pset5 for some time and I end up getting double free or corruptionand don't now how to fix it. Here's my code : /* inside load() */ // some code if(head->children[b] == ...
med yas's user avatar
  • 13
1 vote
1 answer
270 views

pset5 - possessives and substrings

I have posted this questions a few days ago, but none of us were getting anywhere. I thought maybe including my code for load as well as check might yield some new revelations. Anyway, here is the ...
Chris's user avatar
  • 41
1 vote
1 answer
328 views

pset5 unload double free or corruption

* Error in `/home/jharvard/Dropbox/pset5/speller': double free or corruption (top): 0x0804c698 * If I set unload to always return true, load/check work perfectly. Valgrind gives me a lot of invalid ...
J. Willis's user avatar
0 votes
4 answers
267 views

PSET5 Speller: Check50 Can't Compile: Exit code 2 vs 0

At my wit's end here. I've seen this question asked before, but I haven't really found an answer. My speller program compiles perfectly fine in the VS Code workspace. It generates the same results as ...
Steedy Speve's user avatar
0 votes
1 answer
122 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> #...
Pragati Chauhan's user avatar
0 votes
1 answer
72 views

pset5 speller memory errors with valgrind

i've been working in pset5 and cannot make it work. I've read some similar questions and made some improvements to my code, but still can't figure what is wrong. Any tips are welcomed! Here is my code:...
nico_so's user avatar
0 votes
1 answer
183 views

Memory leaks in Speller

My program passes all tests except the valgrind check. I tried to find the cause of errors, but valgrind is too 'obscure' for me yet, I don't know what to do. I guess some memory isn't freed, but I ...
11223342124's user avatar
0 votes
2 answers
154 views

PSet5 Unload(): *** Error in `./speller': double free or corruption (top): 0x0000000002bcb610 *** Aborted

I have been trying to solve this problem for about 3 weeks now...after multiple iterations I just cannot seem to find what I am doing wrong in the load or unload functions to trigger this error. Below ...
Robert Quinn's user avatar
0 votes
1 answer
217 views

CS50 pset5 program is free of memory errors valgrind tests failed;

I'm just minutes away from solving my problem in pset5. But I'm getting the following error from valgrind. ==12523== HEAP SUMMARY: ==12523== in use at exit: 0 bytes in 0 blocks ==12523== total ...
notrealecho's user avatar
0 votes
1 answer
340 views

56 Bytes of leaked memory in speller.c pset5

56 Byte memory leak - not sure where it is coming from. Valgrind points to the malloc'd space for nodnew in the load function - in my first version, I created the pointer nodenew and malloc'd the ...
stygarfield's user avatar
0 votes
1 answer
203 views

dictionary.c not iterating through the linked list, if the hash exists it always returns true

Trying to figure out a bug in my dictionary.c code. Please bear with me as I try to explain the bug. I've been using the debugger, and it seems that anytime there is a collision in my hash table, ...
stygarfield's user avatar
0 votes
1 answer
103 views

PSET5: Check is not working properly...i think

When I test my code...it counts most words as misspelled and only 1 or 2 words as being in dictionary..i presume the issue is in the check function...i do believe the load function works just fine as ...
Ash's user avatar
  • 35
0 votes
1 answer
73 views

can I just return trav->is_word from check?

I've been struggling terribly w/speller. Most recently the check function. I'm troubled by how convoluted my code looks because I see it as indicative of convoluted logic. I most recently generated a ...
Lindsey's user avatar
  • 25
0 votes
1 answer
3k views

incompatible integer to pointer conversion returning 'int' from a function with result type 'struct node *' with custom create_node function

Clang returns an incompatible integer to pointer conversion returning 'int' from a function with result type 'struct node *' error when my create_node function checks whether the ptr malloc returns ...
Lindsey's user avatar
  • 25
0 votes
1 answer
106 views

Stuck on the unload() function. Possibly wrong logic used on load() and check() using tries

I am using tries to complete the spellcheck but I just can't keep up with the logic. I've implemented load() and check() as much as I could but I'm sure it has some logic flaw. The unload() function ...
stackedbooks's user avatar
0 votes
1 answer
46 views

find the leak! pset5

I have run ./test which processes this function: bool unload(void) { //free up memory from linked list for (int i = 0; i < 26; i++) { if (hashtable[i] != NULL) { ...
faelesterio's user avatar
0 votes
2 answers
376 views

Pset5 resize works but fails check50 TODO- bytes and headers match staff bmp file

I know others have had a similar problem and I have tried to find my error but I see no difference between my bmp file and the staff.bmp. Since reddit seems very quiet these days I am posting here ...
NYCJacob's user avatar
0 votes
2 answers
848 views

recover.c only recovers 1 image

I'm having a problem with my code for recover.c because it recovers only 1 JPEG and that JPEG isn't a JPEG. It starts with 0x68 and 0x74. After going through the code with GDB, it seems as that on ...
user1742's user avatar
0 votes
2 answers
787 views

resize vertically doesn't work

First of all I know there are a lot of other questions like this but I have looked at all of them. They have helped a lot but I am still stuck. I can't see anything logically wrong with my code, but ...
Sofia's user avatar
  • 25
0 votes
1 answer
385 views

Recover pset5 scope?

I'm almost there, but one more question about recover.. In my code, I open a file inside an if condition, but how do I acces that file later? It's getting out of scope and I'm getting use of ...
Jesse's user avatar
  • 157
0 votes
1 answer
665 views

Resize.c fails the check "resizes 2x2-pixel BMP to 4x4 correctly when n is 2"

Check50 is failing my code and I am out of options to troubleshoot this. Any help from the community is greatly appreciated. I have compared different resizing factors for small.bmp and smiley.bmp ...
Walter Roncada's user avatar
0 votes
1 answer
294 views

pset5 resize segmentation fault?

I am getting a segmentation fault when I run this program, and am fairly sure that the problem is in the third for loop, where I try to copy the bytes from *pixel to *line, duplicating each byte '...
Jane's user avatar
  • 13
0 votes
1 answer
156 views

CS50 PSET5 Memory Leak (updated2)

I had posted two questions regarding memory leak in Problem Set 5, available at CS50 PSET5 Memory Leak and CS50 PSET5 Memory Leak (updated). I got amazing feedback from different people (and I ...
Alex Chan's user avatar
  • 121