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.
1,172
questions
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
175 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
246 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
450 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
894 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
403 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
290 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
374 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
179 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(...
9
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
358 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 ...
3
votes
1answer
721 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
155 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
329 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
...
12
votes
1answer
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.............................................
8
votes
2answers
2k views
How does fread progress through each byte in copy.c?
In copy.c (and the other apps using the same start code), how does freed know to read one byte after another? It seems to just do it automatically.
Eg, this will read each byte, from first until bi....