Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pset4]

The standard edition of Problem Set 4 will move beyond C programming language basics, testing your knowledge of pointers, memory management, file i/o and structs.

0
votes
1answer
22 views

How to “Insert into linked list for load function”? (pset4 - speller)

I'm currently trying to implement the load function in pset4 speller. The part that I'm having trouble understanding is "insert words into hash table linked lists." My current understanding on ...
0
votes
1answer
11 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
21 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
12 views

speller returning random stuff

My program for speller(hashtable) always returns the following: [1mdictionary.c:35:19:[1m[31m runtime error: [1m[0m[1mmember access within null pointer of type 'node' (aka 'struct node')[1m[0m [...
0
votes
1answer
44 views

I don't get these errors

Every time I compile speller (hash table) I get these errors: clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -Wextra -Wno-sign-...
0
votes
1answer
18 views

pset4 speller trie - Code passes check50 but the output does not match the staff output

Check50 returns all happy faces but my program doesn't find as many mispelled words as it should. I'm not sure if the problem is my check function or my load function I tried checking witih debug50 ...
0
votes
2answers
23 views

How can I have two pset4's ; one from 2018 and one from 2019?

I had completed up to and including pset4 in 2018, and upon resuming in 2019 I was required to resume with the new pset4. How can I have 2 pset4's in the same workspace? For now, I named the 2019 pset ...
0
votes
1answer
26 views

All 50 images look good but failing on middle images on check50 “:( recovers middle images correctly recovered image does not match”

I thought I was there, I was failing on the last image not matching also, but after looking through similar questions I realised that I was checking for EOF before the read of the raw file and not ...
0
votes
1answer
40 views

Pset4, matching with staff solutions,but doesnt pass check50

I compared my output with all keys for every text, and it seems right, but when I use check50 all test cases fail for some reason. My code :https://gist.github.com/Praful932/...
0
votes
1answer
26 views

Pset4 - Recover - Segmentation fault when trying to free buffer

I have run the debug50 and it seems the seg fault occurs after trying to free memory here: // if not start of a new jpeg and we HAVE NOT already found one before if (block_buffer[0] != 0xff &&...
0
votes
1answer
31 views

PSET 4 recover doesn't pass check50 - “recovered images do not match”

All images are recovered, and when I open them, they all display correctly (I checked every one of them in the IDE), yet my program is not passing check50. Why? Here's my code: #include <stdio.h&...
0
votes
1answer
30 views

PSET4 free on malloc in hash function

I'm trying to improve my hash function in Speller and I'm having trouble freeing allocated memmory. I'm getting * Error in `./speller': free(): invalid pointer: 0x0000000001a02252 * Aborted I know ...
0
votes
1answer
27 views

Pset4: Recover - Reach EOF to “early” aka. doesn't recognize beginning of new jpg

I am fighting with the recover challenge in pset4. Had some progress and was able to detect 20 images. But then my condition for finding EOF is true and the program stops. I think the problem is, ...
0
votes
1answer
27 views

Pset4 - recover, unable to pass check50

#include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[1]) { // ensure the arguments are correct if (argc != 2) { fprintf(stderr, "Usage: ./recover filename\n"...
0
votes
1answer
15 views

“check” function in pset4, problem with hashtable and pointers

I'm getting an pesky error when trying to compile my code. error: use of undeclared identifier 'hashtable' first = hashtable[i]; My code, per below, is an attemp to implement the check function ...
0
votes
1answer
84 views

pset4 Speller hash table basics

After struggling with this pset for a while I decided to strip it down to its most basic form and try and understand the implementation of hash tables and linked lists by creating my own. To that end ...
0
votes
1answer
60 views

2018 pset4 dictionary check() doesn't check dictionary

I'm in a pickle here. I have followed walkthrough step by step for this part. But my code just keeps on refusing to load dictionary. (Sorry for the low quality code here) bool load(const char *...
0
votes
1answer
67 views

PSET 4 Speller getting same results as staff solution, but not passing check50

I've been stuck on speller for weeks and decided to move forward to other Problem Sets... and only recently decided to try again... I managed to get it to work and it is getting the same results as ...
0
votes
1answer
59 views

Pset5 Speller (using hash table) unload multiple errors

I have successfully implemented pset5 speller using a hash table, but am facing some residual issues with the unload() function. I am unable to resolve a number of errors that are identified by ...
0
votes
1answer
27 views

Pset4 - Speller: 2d array? Memory?

Does a 2d array make sense as a data structure instead of a linked list? Does it offer any performance benefits? Would it work to implement a hash table that way? Also it seems like the top results ...
0
votes
1answer
94 views

Pset4 - Speller - Unload broken?

I seem to have the load/size functions on point. I'm trying to implement unload before I move on to check, but my valgrind keeps telling me I have a ton of memory left (~8,011,460 bytes) and points ...
0
votes
1answer
28 views

Valgrind 1000000 errors

My code for loading the dictionary in tries is this: // Insert words into trie while (fscanf(file, "%s", word) != EOF) { node *next_node; // Iterate trought every letter of word for (int ...
0
votes
1answer
58 views

CS50 Pset 4 Speller - output stops at “MISSPELLED WORDS”?

After executing speller, the output shows MISSPELLED WORDS and then it stops... I ran debug50 and got this error message for newWord: 0x3 "speller" "cs50" which happened for the code: char *newWord =...
0
votes
1answer
43 views

PSet 4 - getting more misspellt words then staff's solution & a lot of memory leaks

I would very much appreciate it of somebody could tell me what I did wrong or could help me get on the right track to the correct solution. My program overall works fine, except the end result isn't ...
0
votes
1answer
68 views

Pset 3 Recover : segmentation fault for “already found JPEG” loop

I'm having some difficulties understanding the flow of recover. I've used the code and have written the pseudocode like this: if the start of a JPEG file is found - if it is first JPEG, create new ...
0
votes
1answer
76 views

Speller(trie) / my code can't handle most basic words and substrings properly

I need help. When I check my codes through check50, I got a result like below :) dictionary.c and dictionary.h exist :) speller compiles :( handles most basic words properly expected "...
0
votes
1answer
80 views

2019 PSET4 - SPELLER NULL value for “head” node in check()

As per the below, the node "head", created at the top of the check() function, is coming back as NULL. Not sure why, I have checked that the dictionary is put into the hashtable. I have included the ...
0
votes
1answer
50 views

CS50 Pset4 Resize Padding. again

CS50 Pset4 Resize Padding. again I need help! I got lost The code creates a scalable bmp file but is distorted. I think there is a mistake with padding int main(int argc, char* argv[]) { // ...
1
vote
1answer
84 views

pset4 - speller trie load - ptr not linking up

I have been stuck on the load part of the speller exercise for the tries table. I have gone through a lot of the existing questions and come to the following code: while (fscanf(file, "%s", word) != ...
0
votes
1answer
93 views

Stuck for weeks at resize…help needed

I have been stuck at resize(less comfortable) for 3 weeks now. I have written the following code and can't tell why its not resizing and instead IDE is showing that the image is unsupported or invalid....
0
votes
1answer
190 views

CS50 Speller (hash table) - Check returning 0 misspelled words

I'm looking for help with my (hash) code in check to properly handle misspelled words with apostrophes and substrings: bool check(const char *word) { int len = strlen(word); char copy[len + 1]; ...
0
votes
1answer
80 views

resize pset3, getting stuck between the lines

Seems to be working on the first line of resizing, but then something is missing and not copying the correct RGB Triples - the color scheme gets completely off... Have tried playing with all the ...
0
votes
1answer
63 views

PSET4 RECOVER (QUESTIONS)

I managed to make my code recover all 50 images, and have passed check50. However, during the development process I have encountered two problems, and still doesn't get why it is an issue. Here is my ...
0
votes
0answers
21 views

pset4 resize when the factor less than 1

everybody. I am trying a resize problem, it seems when the factor more than 1 works(here my factor is num), but I could not figure out why when the num < 1 doesn't work. It really confused me. My ...
0
votes
1answer
71 views

PSET4 Recover spits out 50 images but they're all invalid

#include <stdio.h> #include <stdint.h> #include <stdlib.h> #define FAT_BLOCK_SIZE 512 // I figured out how to get block size from here "https://cs50.stackexchange.com/...
0
votes
1answer
94 views

Pset 4 resize - problems with resizing

Can anyone help point out what's wrong with my resize algorithm? I have researched and tried out many ways to do it and watched the walkthrough so many times. Here's the resizing part of my code and ...
0
votes
1answer
29 views

How to know the position of the cursor when debugging? PSET4 RESIZE

I am trying to debug PSET4 resize. Is there a way to track the position of the cursor in both the infile and the outfile when debugging (by number or something)? If not, is there a better way to ...
0
votes
2answers
62 views

How to convert char to integer? PSET4

int main(int argc, char *argv[]) //Remembers n int n = *argv[1]; I'm trying to access the value n as an integer. However, when I do this, n stores the ASCII code for the number (I think!). I have ...
0
votes
1answer
46 views

PSET 4 RECOVER - My program outputs 50 images however they all have an invalid format

So I think I've nearly finished but I've come upon a bit of roadblock. That is all my photo are invalid. I looked at all the threads I could and couldn't find out why. My Code: #include <stdio.h&...
0
votes
1answer
18 views

What does this line of code do in copy.c? PSET4

RGBTRIPLE triple; Is this a way to shorten the variable or something?
0
votes
1answer
11 views

What data types is FILE? (PSET4)

I am currently reading through copy.c to try to understand how it works. However, I am confused what data type is this line of code declaring. FILE *inptr = fopen(infile, "r"); I think this is ...
0
votes
1answer
53 views

[Pset 4 resize (less comfortable)]: problem with getting the correct RBG output

I have been stuck at Pset 4 resize (less comfortable) for some time. The program is expected to resize a bmp by a factor n. I get the correct image size but the pixel contents are not correct. Here ...
0
votes
1answer
33 views

pset4 cs50 recover problem jpeg not found

please help me with recover. this is my code.with check 50 i am getting this. :) recover.c exists. :) recover.c compiles. :) handles lack of forensic image :( recovers 000.jpg correctly 000.jpg ...
0
votes
1answer
91 views

pset4: resize (less comfortable)

I am receiving the below when I check Pset4: :) resize.c and bmp.h exist. :) resize.c compiles. :) doesn't resize small.bmp when n is 1 :( resizes small.bmp correctly when n is 2 Byte 22 of pixel ...
0
votes
1answer
39 views

Need help debugging code - PSET 4 recover.c

This is my code: // recovers the location of .jpeg files #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include "bmp.h" int main(int argc, char *argv[]) { // ...
0
votes
1answer
28 views

PSET4 Resize Only works for half an image

So I thought I finished but the image only half way is written. Not sure what I did wrong but the image scales but only the top half. I tried both ways I could think of for the loop but decided using ...
0
votes
1answer
28 views

I have some questions regarding initializing char* in PSET4 - recover

This is the code I've written so far in a couple of hours since I started the assignment. It's still very much wrong so don't really look at it. // recovers the location of .jpeg files #include <...
0
votes
1answer
100 views

PSET 4 - resize.c less

This is my code: // Resizes a BMP file pixel by pixel, given a factor n #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper ...
0
votes
1answer
40 views

Pset4 Colors random

I've looked through a couple of threads and forum questions but I am not able to figure out what are the problems with my code. It resizes correctly but puts out random colors. // Copies a BMP file #...
0
votes
1answer
17 views

PSET4 Invalid File Format when going from n = 1 to n = 2

// Copies a BMP file #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper usage if (argc != 4) { fprintf(stderr, "Please give ...