Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 7539

recover.c, one of the assignments for Problem Set 4, will challenge you to search through the raw bytes of a camera's digital memory to recover a bunch of "deleted" JPEG images.

1 vote
Accepted

Pset4: recover.c -- quitting early without error

Without the full code I can't be sure, but I guess it because the following line: if (check == feof(file)) According to feofs man page: int feof(FILE *stream); The function feof() tests the end-of-f …
ChrisG's user avatar
  • 7,396
1 vote

I don't understand the concept of recover

You are given a raw image of an SD card, and what you have to do is to find the stored JPGs in this file, and restore them as they are. You are not supposed to use your images, just recreate the image …
ChrisG's user avatar
  • 7,396
1 vote
Accepted

Which extension to use?

Use .jpg but there is no difference anyway. It's just what the course checks for. For more info look at this: JPG vs. JPEG image formats
ChrisG's user avatar
  • 7,396
0 votes
Accepted

Recover.c Nothing Happens!

The basic reason your program doesn't produce any jpgs, its because it doesn't find any. That's because you have a typo in the following line: if(buffer[0]==0xff && buffer[1]== 0xd8 && buffer[3] == 0 …
ChrisG's user avatar
  • 7,396
1 vote
Accepted

#pset4 #recover.c segmentation fault

It's a classic buffer overflow error. You store the title of each file in char title[3], but obviously the name of the file is more letters, because it's ['x', 'x', 'x', '.', 'j', 'p', 'g', '\0'], whe …
ChrisG's user avatar
  • 7,396
1 vote

#pset4, #recover.c

Q: Developing JPEGS for pset4's recover troubleshooting. The condition inside your do-while loop is probably wrong. …
ChrisG's user avatar
  • 7,396
1 vote
Accepted

pset4 recover.c. I have no clue on how to start

Your logic is wrong so far, so let's start from the beginning. You read from the file, 512 bytes every time, and you save them in buffer, which is an array of bytes, and 512 places of them. So you can …
ChrisG's user avatar
  • 7,396
1 vote
Accepted

pset4 recover.c seg fault

Let's start from the basic. On every loop, you are reading 2 chunks of 512 bytes into buffer, because there is one fread in the while loop, and one more right after. The fread in the condition stores …
ChrisG's user avatar
  • 7,396
1 vote
Accepted

Naming files in recover.c?

When you open (and create) a file, you do like so: fopen(name, mode); where name and mode are strings. sprintf is exactly like printf, but instead of writing the formatted string you specified to …
ChrisG's user avatar
  • 7,396
1 vote
Accepted

Pset4, check50 correct, but grade 0

Well since your code really does recover all the photos correctly, and it even passes check50 I would say that your code was also checked by a human, and since you have hard-coded the name files, and you …
ChrisG's user avatar
  • 7,396
2 votes

Recover.c- killed by CS50

Did you try to run it on the appliance before checking with check50? I did and it goes in an infinite loop. That's why the server killed it. More precisely the infinite loop is because of your first d …
ChrisG's user avatar
  • 7,396
5 votes

PSET4 recover.c - don't know what's wrong

Just like the error message says, your code doesn't compile, and that because you have included the bmp.h header file on top, which was used in resize and copy, but was included in the bmp directory, …
ChrisG's user avatar
  • 7,396
2 votes
Accepted

Developing JPEGS for pset4's recover troubleshooting

Your code has 3 mistakes that prevent it from working. It's probably just a typo but it's the problem that causes the most damage. Right above the inner while loop you have: fwrite(&buffer, sizeof(bu …
ChrisG's user avatar
  • 7,396
7 votes
Accepted

segmentation fault in recover

Your problem is here: while (fread(buffer, 512, 1, filein)==1) { //if no jpg found and no jpg id then skip if (i == 0 && buffer[0] == 0 && buffer[1] == 0 && buffer[2] == 0 && buffer[3] == 0 …
ChrisG's user avatar
  • 7,396