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
0
votes
1answer
419 views

PSET5 program gets killed everytime I run speller with large dictionary and small dictionary but no error on Valgrind?

Hey guys so I'm working on pset5 and everytime I run my speller with a large dictionary and austinpowers.txt my program gets killed. I've ran valgrind with speller and there are no errors (but also no ...
0
votes
1answer
163 views

pset5 recover seg fault woes

I've been trying to figure out what's going on for a week. Thought maybe someone would be kind enough to point me in the right direction. I get a segmentation fault. I'm not sure the code would work ...
0
votes
1answer
599 views

how do I malloc nodes for use in a trie data structure

How do I use malloc to allocate memory for use in a trie data structure given: typedef struct node { bool in_word; struct node* children[27]; } LETTERNODE; What is the syntax for malloc in ...
0
votes
1answer
187 views

pset5 why only strcpy works

In load, when I assign the word I loaded from dictionary to new_node, I originally used new_node->word = new_word but an error told me that it is non assignable. However, when I use strcpy it ...
3
votes
1answer
2k views

pset5 getrusage in speller.c

What are "before" and "after" used in getrusage? Why and how they are used? I also find manuel's explanation about RUSAGE_SELF hard to understand. Thanks in advance.
0
votes
2answers
111 views

About Spanish and PSET 4

I notice that CS50 is doing a really effort to make the course more accesible to everyone, and you can see this below the videos is a lot subtitles links in many languages. So, in PSET 4 there is a ...
0
votes
0answers
65 views

compiling errors

I'm dealing with pset5 (speller.c), and I chose trie to run the program. when I compiled it, it said: dictionary.c:25:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] root ...
1
vote
2answers
3k views

Try to use trie in pset5

I know if I want to use trie in pset5 to load the dictionary, there should be a struct containing an array of pointers for the alphabets or the apostrophe and a variable of bool. The question is, ...
1
vote
2answers
3k views

How to interpret biHeight data

I am having trouble with biHeight from the header info of bmp files. In the file small.bmp, from pset5, that is 3X3 pixels: biHeight has the value fffffffd. I would expect it to be the same as the ...
0
votes
0answers
330 views

Initially running speller using the staffs dictionary

When trying to run ./speller, I ran ./speller text to see it in action. I received the error: Could not load /home/cs50/pset5/dictionaries/large. I went to /home/cs50/pset5/dictionaries, and the ...
1
vote
1answer
580 views

CS50x 2015 pset5 check50 & submission problem

SITUATION I enrolled in CS50x in late 2014. The class ended on 12/31/2014 and I was not able to finish in time. Enrolled in CS50x3 in 2015 and re-submitting my completed work where appropriate. ...
0
votes
0answers
105 views

pset5 picture problems: jpg recovery

I have two main problems with recover: Does not recover 049.jpg - Is this because my program is getting a freak EOF? check50 hates me - Although my program recovers 000.jpg through 048.jpg fine, ...
1
vote
1answer
934 views

what is wrong with my resize?

My resize program isn't working. I have narrowed it down to the padding, but cannot find what is incorrect. It resizes images that don't need padding perfectly (multiples of 4), and the header ...
1
vote
2answers
265 views

i'm able to recover the 49th image but does check50 says unable to recover the 49th image

I spent hours but still then i'm not able to understand that why does check50 does not recognize my 49th recovered image eventhough i have recovered that image and i can see that the image is of ...
0
votes
1answer
517 views

Pset5 Recover Only Generating 49 images

To start, I've come a long way because I have gotten lots of help looking over all other questions & answers here, thank you!! Currently, I can run recover.c successfully, and it will recover ...
1
vote
1answer
693 views

why image color is not changing in whodunit?

I have made the below mentioned changes in my whodunit file but still the new image that is created is exactly similar to clue.bmp someone please help...
0
votes
1answer
72 views

Zip error pset 5

Zipping pset5 fails. How to deal with this error? I can zip manually but don't know exactly which files to include. jharvard@appliance (~/Dropbox/pset5/jpg): zip -r pset5.zip pset5/ -i "*.c" "*.h" "*...
1
vote
1answer
390 views

my .bmp files are not opening up but rather showing the error unable to open the file

whenever i tries to open smiley.bmp and other .bmp format files i gets the error 'problem opening the file ' I have downloaded my pset5 again but still then i'm getting the same error. I also wanted ...
0
votes
1answer
204 views

PSET5 Resize returns image of jubbled colours … not sure what's wrong!

For PSET5 Resize.c, I have tried implementing the following with n being the resize factor inputted by the user. The code compiles but returns an image of an conglumeration of colours (or a corrupted ...
1
vote
0answers
209 views

pset5: Resize does not consistently work

I am having a problem with resize. I can resize smiley.bmp perfectly at X1, X2, and X10, but not for factors between 2 and 10--I just get an abstract blob of colors. I assume this has something to do ...
0
votes
1answer
84 views

Cant validate whether file being read is JPEG or not in recover

I cannot validate whether the file is JPEG or not with a help of the pattern. Thanks in advance. Here is my simple code: typedef uint8_t BYTE; int main(int argc, char* argv[]) { char* ...
0
votes
1answer
605 views

Resize.c not working in some cases

I'm struggling with resize.c for quite some time. I've come to the point where it perfectly resizes sometimes (for example, small.bmp with factor 5) but sometimes it doesnt(for example, small.bmp with ...
3
votes
1answer
1k views

pset 5 resize vertically - use of fseek

I am struggling with the vertical resizing using the recopy approach. I read a pseudocode in an answer to another question in this forum and am trying to code it. I feel I am near but something is not ...
0
votes
1answer
366 views

How do I add leading zeros to the filename in `recover`?

I wrote a perfectly functional recover.c program yesterday. But I can't get the file naming right. How can I add leading zeroes to the file name so the name is 000 instead of just 0?
0
votes
1answer
379 views

Why do these 3 lines cause a segmentation fault?

The memcpy line is causing a segmentation fault. Can you help me understand why? (A BYTE is a uint8_t). It still causes a segmentation fault if I change the size of the buffer to sizeof(BYTE)*512. ...
2
votes
1answer
95 views

Why should we assume that the size of the output BMP file does not exceed 4 GB?

Per the spec of pset5, You’re welcome to get started by copying (yet again) copy.c and naming the copy resize.c. But spend some time thinking about what it means to resize a BMP. (You may ...
0
votes
0answers
97 views

Resize.c Lines are shifted

I have been trying to debug my code for days now with little success. The enlarged image seems shifted when I open it. The white pixels in the middle are skewed off center, though my file is the ...
1
vote
3answers
421 views

pset5 resize working (IMO) but check50 says it's not

I'm having a bit of an issue here.. I wrote the resize.c function for pset5 and it is working - I am getting the expected results - I can see my file being resized and it looks alright in image ...
0
votes
1answer
896 views

Recover Buffer as uint8_t instead of int

I have been struggling through Recover when I noticed that the buffer on the walk through was a BYTE buffer; instead of just an int buffer;. After changing this my program finally worked! My ...
0
votes
1answer
139 views

Infinite loop and unable to check for next JPG

My program is stuck in a loop and I can't figure out why. The problem is in the do while loop but logically it should work. The program checks performs fwrite and then freads a new 512 bytes to the ...
0
votes
1answer
161 views

pset5 resize correct, cs50 check indicates error and prints two “TODO's”

"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 ...
0
votes
1answer
114 views

unable to use structs to compare with bytes stored in buffer

my recover program keeps coming up with error invalid operands to binary expression at the line where I check if(buffer[0] == pattern1 || buffer[0] == pattern2) I'm not sure why this error occurs ...
-1
votes
1answer
160 views

resizing problem

check50 shows that i cant resize 1x1px image by 2 and 3, others are fine and i don't know why....can anyone give me some hints. thanks. My headers are fine as i checked... // read infile's ...
1
vote
2answers
668 views

What is the meaning of this segmentation fault?

For recover.c my program compiles but when I run gdb I get a segmentation fault and I'm not quite sure what it means. When I run gdb I reach line 59 before I get this error message. I would like to ...
0
votes
1answer
656 views

Not sure why resize.c isn't working

resize.c compiles and runs, but produces an image with a lot of black space. A fresh set of eyes on my code is welcome to see where I have gone wrong. I assume it has to do with padding but I can't ...
1
vote
1answer
176 views

A question about padding

So in copy.c the formula for padding is: padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; which I don't quite understand. For example (to my understanding) if the image is 3x3 the padding ...
0
votes
1answer
523 views

Pset5 Resize padding issues

After a lot of time, my resize finally works for the original conditions, that is, scale of 4. However, when I try a scale of 3 or 5, my program suddenly contains a lot of black slides, instead of ...
0
votes
0answers
154 views

Unable to solve resize.c

Hello guys I am stuck at pset-5 resize.c problem. Here is what i have done: 1) For updating header, in width and height, ave multiplied them by n and for Image size, subtracted the padding of input ...
0
votes
2answers
370 views

Getting the vertical scaling right in pset5

I've got resize working to the point where it resizes horizontally, but not vertically. Here is the code: // iterate over infile's scanlines for (int i = 0, biHeight = abs(old_biHeight); i < ...
-1
votes
1answer
377 views

Recover Never Stops

I've been slowly moving through recover, and have figured out how to recover all 50 images. Unfortunately, the program never stops running (I hit ctrl + c to stop it) and the 50th image, while ...
1
vote
1answer
201 views

Is my pset5 resize working or not?

When I try to run my ./resize 4 small.bmp large.bmp I get this: jharvard@appliance (~/Dropbox/pset5/bmp): ./resize 4 small.bmp large.bmp Could not open 4. Check50 seems to say that I have extraneous ...
7
votes
1answer
8k views

What is the difference between bfSize and biSizeImage?

I'm working through pset5's resize right now and I'm at the point where I've got to update the headers for the new file. I'm having trouble computing them, mainly because I can't really tell the ...
0
votes
0answers
149 views

All pictures recovered, Valgrind OK, but Check50 won´t accept the pictures

I was thrilled to see that all the pictures were recovered to the jpg-folder with the correct filenames, but shocked to see that my program was still running! I had to Ctrl + C to end it. I managed ...
0
votes
1answer
460 views

pset5-recover help

UPDATE-1 #include <stdio.h> #include <stdint.h> #include <ctype.h> typedef uint8_t BYTE; typedef struct { BYTE buff[512]; } __attribute__((__packed__)) BUFFER; int main() { ...
0
votes
1answer
188 views

Why is file pointer null on Whodunit and how can I fix?

(gdb) b main Breakpoint 1 at 0x804869e: file whodunit.c, line 18. (gdb) r infile outfile Starting program: /home/jharvard/Dropbox/pset5/bmp/whodunit infile outfile Breakpoint 1, main (argc=3, argv=...
-1
votes
1answer
335 views

Problem with resize

I'm with the pset5 and my code doesn't work and I don't know why. Can somebody help me? Here is my code: //resize headers BITMAPFILEHEADER bfNew; BITMAPINFOHEADER biNew; biNew.biWidth = bi.biWidth * ...
1
vote
2answers
634 views

check50 says “bmp.h” not found even though “bmp.h” is in jpg directory

Hello all I have a question about compiling what I've written for recover.c The compiler shows me this message when I try to compile recover: " expected an exit code of 0, not standard error of ...
0
votes
2answers
109 views

trouble with pointers in bi and bf headers

So I am playing around with copy.c in Forensics. I am trying to figure out how to use pointers. After I run the lines where it reads the headers (ie fread(&bf, sizeof(BITMAPFILEHEADER), 1, inptr) ...
1
vote
1answer
558 views

How is biSizeImage calculated for a 1x1 BMP with n = 1?

I'm so close, but my program does not pass check50 because it doesn't resize a 1x1 BMP correctly when n is 1, 2, 3, 5 (i.e., when it needs padding). When I use peek to compare with staff for 1x1 and ...
1
vote
1answer
191 views

Resizing small.bmp with n=4 gives an image with a black rectangle on the bottom left corner

When I try my resize program on small.bmp and enter 4 as n, it gives me a 12x12 picture that is all green, but instead of having the white little square in the middle it has a black rectangle on the ...