Search Results
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 |
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
Last cs50 check not working help pls sos, I'm a beginner in C!
This is a common error. The last file doesn't match because it's 512 bytes too large. The code checks for EOF, then it reads in another 512 bytes, processes it and checks again for EOF.
The problem …
1
vote
Accepted
Recover used to make files and now doesn't (Spoiler Alert)
Let's look at some of the code:
while (fread(temp, sizeof(unsigned char), 1, file) != 0)
{
// Read 512 bytes from the inputted file to the temporary array
fread(temp, 1, 512, file);
// If …
2
votes
Accepted
why does my recover find only 8 JPGs?
Your code is recovering every other jpeg file because of a logic/structure issue. You have set up your code to do this:
read blocks until it finds a jpeg signature
write the signature block to a new …
1
vote
Accepted
1st image works, but the rest don't work (although thumbnails show up on several of them)
The inner test isn't valid. The line
while (buffer[0] != jpg_sig1[0] &&
buffer[1] != jpg_sig1[1] &&
buffer[2] != jpg_sig1[2] &&
(buffer[3] != jpg_sig1[3] ||
…
1
vote
Accepted
pset4 recover cant find headers
Let's assume that the missing } is a cut and paste typo and move on. ;-)
The problem is that you have TWO fread() calls. You are failing to process every other 512 byte block of code because it is re …
1
vote
Recover not returning images
Look at your file open:
FILE* outptr = fopen("title","a");
You are literally naming every file "title". If you do an ls -al you will probably see it in the listing. Maybe you should remove …
1
vote
Accepted
Data in recover.c doesn't seem to be aligned at 512-byte intervals... what am I missing?
There are a number of issues. The code is reading 4*1 bytes at a time, not 1, and not 512. This won't work because an actual signature must appear on a 512 byte boundary. It is possible that by chanc …
1
vote
Data in recover.c doesn't seem to be aligned at 512-byte intervals... what am I missing?
To answer your comments, you're starting to catch on. First, reading or writing to/from outside storage (We'll call that r/w from now on, unless specifying one or the other) is always slower than r/w …
0
votes
guys here is my code of recover it recovers every image but still check50 disagrees
It recovers the files, but they are 512 bytes too long. There are two issues with your code.
First, the logic flow is flawed. Once the first output file is opened, the code reads in a 512 byte block …
0
votes
The IF in recover
The last comparison is a two part sequence. The first part is what is called a mask and the second part is the comparison.
(array[3] & 0xf0) == 0xe0
Remember that this check of the 4th byte o …
2
votes
Accepted
Recover - images are blurry and incomplete
Let's look at the following and see what it does:
while(fread(buffer, 512,1,inptr) == 1){
// new jpeg
if(buffer[0] == 0xff &&
buffer[1] == 0xd8 &&
buffer[2] == 0xff &&
(buf …
1
vote
Pset4 Recover - Error using fclose
Sometimes the simple fix is best. Try initializing the file pointer - always a good idea anyways:
FILE* jpegptr = NULL;
While it may be that the code will work (I'd have to test it to see), th …
2
votes
Accepted
Recover.c; Need explanation about how to implement "write 512 bytes until the new jpeg is fo...
How about an explanation instead. Image files are not just 512 bytes long. They can be any size. The assignment is saying this. You need to read in blocks of data that are 512 bytes long and check …
1
vote
Fread doesn't return new values to buffer - recover - pset4
One major fix is to change this line:
img = fopen(image, "w");
It's opening the input file for write! That will erase the current contents of the input file and just cause all kinds of pro …
0
votes
Accepted
i have tried it with small diffs a lot of times.i feel more comfortable about this, but stil...
There are a couple of issues in the code. First, it opens the output files in "a" or append mode. By doing this, if you've run the program before and the files already exist, it will just add more da …