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
1answer
2k views

recover end of file detection

I'm having a lot of trouble with recover. I have written some code, just to get the basic structure. I was trying to iterate over the raw file until the end, printing when stumbled upon a jpeg. ...
0
votes
1answer
1k views

Updating header info in resize

I know I have to do this: //resize headers biWidth = biWidth * n biHeight = biHeight * n biSizeImage = (biHeight*3) * (biWidth*3) + padding bfSize = biSizeImage + 54 But I don't know ...
0
votes
1answer
708 views

How to use fseek in resize and what's wrong with my code?

The resize assignment has had me spinning in circles for the past few weeks. Could someone give me an example of how to use fseek and point out the logic errors in my code? for (int i = 0, biHeight = ...
4
votes
1answer
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?
0
votes
1answer
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 ...
0
votes
1answer
476 views

PSET5: Trouble with CHECK50 and resize.c. Stuck with this problem [duplicate]

While submitting resize.c to check50 in pset5, I get the following results: check50 2014/x/pset5/resize bmp.h resize.c :) resize.c and bmp.h exist :) resize.c compiles :) doesn't resize 1x1-pixel ...
0
votes
1answer
59 views

Pset5 is missing from the web site

I just watched the Week 5 lecture and now I notice there is no pset5 accessible on the web site. Do I miss something here? I also notice that there is no Week 6 on the web site.
0
votes
1answer
168 views

pset5 resize file io fread

Among the recommended reading list for this pset was this page (http://www.cprogramming.com/tutorial/cfileio.html), which indicates that when using fopen specifically for reading or writing in binary, ...
0
votes
2answers
675 views

pset5 resize re-copy method

I'm trying to resize bmp files in Pset 5 using the re-copy method. However, it seems as though I'm calculating the headers wrongly and I'm also not implementing the for loop where I repeat the ...
0
votes
1answer
212 views

Conceptualising resizing in pset5

I've just solved the resizing part of pset5 without completely understanding what is happening during the reading of the infile and writing of the outfile bit. To clarify my question, here is my code ...
2
votes
1answer
1k views

Can't recover 049.jpg successfully

The 049.jpg file is created but not recovered! I have used the fread function to detect the EOF as told in the walk through by Zamyla. Here is a link to the check50 sandbox output. # Checks 0 ...
1
vote
1answer
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 ...
0
votes
1answer
178 views

pset5 resize, not enough memory to load bmp

Resize is compiling but the outfile bmp doesn't open. It gives me an error "Not enough memory to load bmp". Does anybody have any idea why that might be happening? Where am I going wrong? Here's my ...
0
votes
1answer
135 views

JPEG output files are blank

All of my program seems to be functioning but my JPEG images are completely blank. I'm not sure, but I think the error is somewhere in this code: if ((buffer[0] == 0xFF) && (buffer[1] == 0xD8)...
0
votes
1answer
651 views

pset5 recover error with jpeg file

I keep getting "error interpreting jpeg image file (Not a jpeg file: starts with 0x00 0xd8)", even though gdb tells me buffer[0] is 0xff. A similar question has been posted on reddit, but I couldn't ...
0
votes
1answer
294 views

Serious problems with pset5 resize - alterations to headers [closed]

I'm really struggling with this pset, and resize especially - I have gone through the code, but I don't know what I am missing. I could really use someone to take a look at the code and point me in ...
1
vote
1answer
510 views

adding padding into resize

I know my paddingOld & paddingNew values are correct. I also know all my header info is correct (checked student vs staff) check 50 passes the cases that do not need padding, but fails the ones ...
2
votes
2answers
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 ...
1
vote
1answer
118 views

Can anyone tell why is this giving me a SEGFAULT?

typedef uint8_t BYTE; int main(void) { FILE* memcard = fopen("card.raw", "r"); if (memcard == NULL) { printf("something went wrong and file could not be opened"); return ...
0
votes
0answers
182 views

check50 fails my pset 5 resize.c even though output is identical to staff's implementation

I ran diff with the bmp file outputted by my resize program and the same bmp file outputted by the staff's implementation, and it says that the two files are identical; but check50 says it doesn't ...
0
votes
1answer
776 views

Seg Fault in Recover.c

I cannot seem to get to get rid of this seg fault. In my loop I basically have this (semi-pseudo code): fread(in); if(nf == 0xffd8ffe0 || nf == 0xffd8ffe1) { f++; fclose(out); ...
1
vote
1answer
870 views

Pset 5 - Recover

Having problems with recover (pset5) now. This is what I'm doing: Opening File Until the end of file Reading 512 bytes to buffer Checking first 4 bytes of buffer to see if a jpg has just ...
2
votes
2answers
4k views

Pset 5 - Resize

I'm having problems with the header manipulation. My code seems to factor well images but it doesn't calculate well bi.biSizeImage and bf.bfSize. This is what I've done: // read infile's ...
0
votes
1answer
1k views

Resize vertical help

After looking at several similar questions, I still cannot figure out why my code is not working! here is my vertical (this is in the beginning of the outer loop): if(a <= n) { ...
1
vote
1answer
377 views

Recover.c Segmentation Fault

Pseudocode: declare counter declare filename[8] main Open input Declare buffer do read(512 bytes into buffer from input) while (not start of jpeg) do write filename open ...
0
votes
1answer
557 views

How to implement re-copy method for resize?

I have been through my code a few times aloud and on paper and have hit a brick wall. I'd rather get a hold on the re-copy method before bottling it and trying the re-write method. // iterate over ...
9
votes
1answer
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 ...
0
votes
1answer
2k views

Pset5 - Whodunit

What do we have to do in Pset 5 : Whodunit? I know we need to analyze a file, but all I see is a lot of red pixels.
0
votes
1answer
291 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 '...
1
vote
1answer
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 ...
0
votes
1answer
1k views

segmentation fault - pset5 recover.c

I have spent a long time looking through my code for a segmentation fault, but have not been able to find it. #include <stdio.h> #include <stdlib.h> #include <stdint.h> #define ...
1
vote
1answer
3k views

Cannot figure out what is wrong with recover - “Improper call to JPEG library in state 201”

Does anyone know why I might be receiving this error in my recover program? I've used xxd to confirm that the first four bytes are correct and signal that each is a jpeg. However, I am still receiving ...
1
vote
2answers
177 views

Trouble incrementing the number in jpeg filenames

I've gotten recover to work... sort of. The problem is difficult to describe without posting my code, but here's an attempt: My program can find all the jpg signatures (in GDB, my jpeg-finding line ...
1
vote
1answer
247 views

what is happening in pset5 resize hacker edition?

I implemented the staff's solution to compress a bmp by a factor say 0.5 and compared the compressed version with the original bmp using xxd command. I expected it copy just half of rgb triples from ...
0
votes
1answer
397 views

How does the “re-copy method” work?

So, in Zamyla's walkthrough, she says that for the "Re-Copy" method of vertical resizing, you have to go back to the start of the original row, and then repeat the horizontal resizing. I don't ...
0
votes
1answer
581 views

fread reaches eof prematurely (pset 5)

Scratching my head on this one folks. My current program reads the first two chunks of 512 bytes of the first jpg (thats actually 3 reads total as the first 512 chunk is empty), but then fread fails ...
0
votes
1answer
2k views

How to Resize an Image Vertically?

I'm able to resize a given .bmp horizontally, but the code for vertical resizing is not working. Here is my code for vertical expansion. // resize vertically //move pointer to start of scanline of ...
3
votes
3answers
998 views

Proper use of fread function

I have declared a buffer as follows : unsigned int buffer[512]; Now, later on in my code I used fread in the following manner fread(buffer, 512, 1, infile) and everything worked as expected. Note ...
2
votes
2answers
412 views

Is it possible to see the actual bytes of card.raw?

Is it possible to see the actual bytes of card.raw from pset5?
1
vote
1answer
120 views

Why is this condition true if the characters in the buffer do not match?

As you can see, the if statement on the line 35 is false. Why is the body of the if statement being executed?
0
votes
2answers
331 views

Why am I not able to write n elements of a specific size correctly?

Given these two blocks of code fwrite(&x, sizeof(y), n, z); And for (int i = 0; i < n; i++) { fwrite(&x, sizeof(y), 1, z); } I was actually working on resize when my resized images ...
0
votes
2answers
375 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 ...
0
votes
2answers
183 views

Why Do We Add a char (A Byte) While We Need 3 Bytes?

In copy.c, in case we're copying a 3x3 bmp image, this piece of code adds the calculated padding to the bmp // then add it back (to demonstrate how) for (int k = 0; k < padding; k++) { fputc(...
10
votes
1answer
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?
5
votes
2answers
359 views

Why Are There Some Missing Psets and Weeks?

So, i just finished the continued lecture on week 5, and then I was going to make the pset 5, but I noticed that it is on Week 7 page, and I noticed that there is no week 6 page, is that normal? Or ...
4
votes
1answer
896 views

What Does __attribute__((__packed__)) Do?

I understand the idea that each scanline should have a number of bytes that is a multiple of 4. Otherwise, the BMP is stored in a such a way that each scanline is padded with as many zeros as it takes ...
1
vote
2answers
185 views

How to build a “.raw ” image of a storage media?

In pset 5 David gave us his SD card's card.raw file to recover deleted JPEG images from. What are these .raw disk images and how can we build them to create practice problems similar to pset 5 for ...
-1
votes
3answers
330 views

Why Doesn't check50 Recognize My Recovered Images?

when I use check50 to check my recover program for pset 5, it says that the pictures are not recovered, but when I look in the file directory, all of the 50 pictures are perfectly recovered. How could ...
1
vote
1answer
375 views

pset 5 resize.cdoes not resize properly. works visually for smiley.bmp but not for small.bmp

Theses are my observations so far: It can resize the smiley.bmp properly without distorting the image. What I'm not sure about is whether or not the contents of its headers are right. It can resize ...
0
votes
1answer
595 views

recover.c recovers all images successfully, but check50 says it fails to recover the last. Any ideas why this is happening?

I have a while (!feof(infile)) loop, so that exits only when the eof is reached. And it closes all files upon exit. Here's the code: // scan input file while (!feof(infile)) { // read four bytes ...