Hot answers tagged

3 votes

PSET4 RECOVER Can't Open JPEGS, I Have Tried Everything Please HELP!

[EDIT: followup to comments] The code never has a chance to get to a signature. There exists more than one block of garbage data at the front of the file, so the while loop needs to run a few ...
Cliff B's user avatar
  • 68.7k
2 votes
Accepted

PSET4 recover.c not quite working / 98% blank JPEGs

your program works perfectly, congratulations, there is only a "small error" (buffer[0] = 0xff) it should be (buffer[0] ==0xff)
MARS's user avatar
  • 5,169
2 votes
Accepted

PSET4 Recover Can't Open JPEGs in the IDE

Can you give me an example of a filename that is supposed to contain a line feed? sprintf(outfile, "%03i.jpg\n", foundPhoto); As a side note, a programming tip. When you see to nearly ...
Cliff B's user avatar
  • 68.7k
2 votes
Accepted

Having some tough time with pset4 recover.c

Seems to me that there were 50 files when I did this. They may have changed the data file again though. Having said that, look at the following: while (fread(buffer, 1, 512, infile) == 512) { //...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

pset4 recover doesn't recognize jpegs

Program is not producing any jpgs because it is reading itself. Recall from the lecture the first element in argv is the program's name, so the problem is here. FILE *card = fopen(argv[0],"r"...
DinoCoderSaurus's user avatar
1 vote

CS50 PSet4 Recover fails Check50

Are you sure that you are remaking the file after editing it, and that you're rebuilding the file that you're actually editing? Or that you're running the 2020 check50 slug? check50 cs50/problems/2020/...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

CS50 Pset4 Logic Problem

I think the issue is with this line of code: while (fread(block, sizeof(block), 1, input) == 1) fread returns the number of items successfully read. So, if it successfully reads 1 block of data, it ...
John Yang's user avatar
1 vote
Accepted

recover.c producing random image 🙁

You fread two blocks, but fwrite one. Remove the first fread. You don't seem to increment fileCount if it is 0. Which is a problem, as it will never leave its value of 0. Please don't use & when ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Problem Set 4 Recover Issues. I can't figure out why my code doesn't work

You have multiple fread, each reading 512 bytes, but not every read sector seems to be written even after opening a file. This means you're skipping some sectors. Instead of a do..while loop, use a ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Segmentation fault on recover pset4

The first step is to identify which line is triggering the seg fault. When the code writes to the output file, has the file been opened yet? If this answers your question, please click on the check ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

No JPEG images printed in recover.c

The program never finds a jpg signature because this test (buffer[3] & 0xf) == 0xe0) is wrong. Suggest you review this answer by @Cliff B for an excellent explanation. After you sort that out, ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Why data recovery isn’t an exact science?

It means exactly what it says. If you find a signature pattern, the chances are high that this will mark the start of an image file. BUT, its also possible that there is stored data that will match a ...
Cliff B's user avatar
  • 68.7k
1 vote

Why data recovery isn’t an exact science?

Those 4 bytes might appear and not be part of a jpg at all. The point is that if you find those 4 bytes, they probably signify the beginning of a jpg, but they might not.
curiouskiwi's user avatar
  • 18.6k
1 vote
Accepted

Pset4 - Recover - Not able to find jpegs in card.raw

Since counter is reset to 0 after every fread, it will never be 40. Perhaps filter out the noise by making the else condition something different, perhaps printf("."); to just "mark" a read. IMO you'...
DinoCoderSaurus's user avatar
1 vote

recover images from raw file (pset4)

One thing not accounted for in this design is the possibility of finding a "false jpg sig" in the middle of a 512-byte block. Recall from the spec: Thanks to FAT, you can trust that JPEGs' ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset4/recover: i see files but not all of it and nothing in it

It's amazing how often one small oversight can trash an entire program! Welcome to the wonderful world of "Oops, I missed something small!" We all get this, more often than we care to admit! ;-) The ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

Pset4 recover.c compliles but can't open jpeg

Are you sure this code is recovering all 50 jpgs? It seems to me like you're missing half the files and only recovering 25 pics, because you're calling fread here: fread(buffer, sizeof(BYTE)*512 , 1,...
Yuri Laguardia's user avatar
1 vote

Jpeg image files format not supported

while(!feof(fp)) Review Week 4 > Shorts > File I/O (starting at 7:30) to remember why you shouldn't use !feof to control the while loop. fread(&buffer,32,1,fp); 32? From the spec: cameras only ...
DinoCoderSaurus's user avatar
1 vote

PSET4 recover.c not quite working / 98% blank JPEGs

I just finished the PSET myself but was browsing here because I was struggling with a segmentation error. Anyway, noticed that our structure of the code is pretty much identical. I only noticed one ...
Mike224's user avatar
  • 11

Only top scored, non community-wiki answers of a minimum length are eligible