Questions tagged [recover]

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.

Filter by
Sorted by
Tagged with
7
votes
1answer
872 views

Help me write sexier code : ) counters as pointers, buffering files, feof, sprintf [pset4.recover]

I have completed the pset, and am happy with my code and how it works. But had some design questions so that I know for future programs what and why to use. I understand that it does not really ...
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?
3
votes
1answer
1k views

pset 4 recover - Bitwise operator

I'm on pset 4 recover and stuck, trying to understand the bitwise operator, if (buffer[3] & 0xf0) == 0xe0) Can someone tell me if my understanding is correct? The if condition checks the value at ...
3
votes
3answers
868 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
1answer
1k views

pset4 recover I'm confused with fread

I'm pretty confused with recover. I've seen in previous posts that it is wrong to use feof , but the problem is that when I use fread the images won't show. However, when I use feof I can see all ...
2
votes
2answers
269 views

pset4 recover: recovered images seems to still be corrupted

My code compiles and runs without any errors. Images are generated, but the images are incomplete, here's an example of 000.jpg: https://i.imgur.com/Ovs2Xv8.png. I can't really find what's wrong in my ...
2
votes
2answers
643 views

Pset4 recover, comparing hex in if statements

I'm trying to solve "recover" but, I'm unable to compare my if statements. This is my error message: error: comparison of constant 224 with expression of type 'char' is always false [-...
2
votes
1answer
2k views

cs50 pset 4 Recover - I get 50 blank images of different sizes

I cannot figure out where in heck I've gone wrong with this program. It outputs 50 files, numbered correctly and with different sizes. However, they are all blank. When I run "head -q -c4 *.jpg | ...
2
votes
2answers
2k views

segmentation fault, probably because of sprintf

for my recover.c i have trouble changing the filenames. I get a segmentation fault probably because of incorrect usage of sprintf. Code looks sort of like this: { // pseudocode for testing ...
2
votes
2answers
397 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?
2
votes
2answers
775 views

jpg's fourth byte

Reviewing my code after successfully recovering the images in pset4, I see a part I just copied (from Zamyla's video) without understanding. Mainly, the following: (block[3] & 0xf0) == 0xe0 I ...
2
votes
1answer
1k views

Recover where to start from?

I finished resize after spending days on it and took a week break, today I read what recover is and after reading it I am having that feeling as to what to do where to start from? Have spend like ours ...
2
votes
1answer
959 views

:( recovers 049.jpg correctly recovered image does not match

I have problem with pset4/recover. I recover all images and can see last image when I click on it but when I run check50 it returns with error: :( recovers 049.jpg correctly recovered image does not ...
2
votes
1answer
132 views

Recover makes file for JPG but gives strange output

I've been staring at this for days and can't seem to find what's wrong. My code compiles, makes a file for the JPG's found, only doesn't show the JPG's but a weird screen full of symbols in white and ...
2
votes
1answer
266 views

Comparing jpg-signatures with fread-buffer; Can't find something

Using the if condition I am trying to compare the buffer with the given jpg signatures, but I never find something. In GDB I just see the while looping, but never entering the if condition. What have ...
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 ...
2
votes
1answer
243 views

my pset4 recover grading is 0

my pset4 recover grading is 0. However comment shows all the images recovered successfully. How can I get my grades corrected. Also, all images recovered successfully on my cs50 applaince. check50 ...
2
votes
1answer
213 views

why does my program recover only 3 JPEGs correctly?

When I run my recover program, it makes 16 JPG images. 3 of these JPG images (specifically, the 3rd, 8th, and 9th images) are perfect. The others, however, display question marks. When I try to open ...
2
votes
1answer
323 views

Recover creates an unreadable image file and then segfaults

I am pulling my hair out over recover.c in pset5. My code manages to generate 1 appropriately named (but unreadable) jpg and then fails with segmentation fault. I have tried to figure it out by ...
1
vote
1answer
1k views

What is the difference in behavior between fread and feof?

For pset4's recover.c code, I noticed the following: when I set my while loop to be while (!feof(inptr)), all the images get recovered, including the last, but check50 throws an error (TODO) when ...
1
vote
2answers
147 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
vote
2answers
155 views

in pset4, resize: How does the structs declared in 'bmp.h' know which bytes to get the data from?

I managed to complete the pset4/resize, but am having difficulty understanding the concept behind how it works. That gap is showing up in my attempt at pset4/jpg. fread as far as I know doesn't tell ...
1
vote
2answers
201 views

sprintf compile error

I seem to be having a problem with sprintf, the compiler gives me an error. char* title = sprintf("%03d.jpg", counter); The above gives me the following response in the compiler: recover.c:39:39: ...
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
520 views

pset4 check50 2016.recover recover.c is working correctly?

I'm not sure if check50 is working correctly? When i run my code, i recover all 50 jpg and i can view them. This is what i get when i run check50 2016.recover recover.c :) recover.c exists :) ...
1
vote
1answer
523 views

recover.c cannot detect jpeg signatures?

Trying to get my recover.c to work. My program fread's 512 bytes into a buffer on every iteration of a loop. The buffer is declared as so: unsigned int* cfbfr = malloc(512); Then, at the start of ...
1
vote
1answer
182 views

My code works, but dont know why it is char filename[7]. Why 7? Why not another number?

My code works, but dont know why it is char filename[7]. Why 7? Why not another number?Thanks. // create filename char filename[7]; sprintf(filename, "%03i.jpg", ...
1
vote
1answer
605 views

PSET4 - Recover - Undeclared Identifier “img”

I keep trying to compile this code and it tells me "img" is an undeclared identifier. If I try to declare it, it tells me I'm shadowing a local variable. I'm not sure what the solution is. I have ...
1
vote
2answers
4k views

**SPOILER - COMPLETED PSET** improve CS50 pset4 recover with functions

I've managed to make a working copy of CS50 resize. However, in order to adhere to the thought of not repeating myself, have tried to create a function to create a new file. The program at present ...
1
vote
2answers
394 views

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

my first post and would appreciate some feedback. I'm taking CS50 online, and the course assumes a lot, especially from someone like me who's only taking up coding again after 15 years (think Basic &...
1
vote
1answer
411 views

Pset4 Recover - Why do we need to check if JPG is already found?

I'm having trouble reading and writing the contents of the JPG files in Pset4 recover. When I run my program, I'm getting all 50 JPGs as files 000.jpg to 049.jpg. However, the pictures all appear to ...
1
vote
1answer
632 views

Recover creates the pictures, able to view them, but listed as jpg? in ls and check50 fails

I checked the boards and couldn't find if anyone else had the same issue. For some reason, Recover runs 'seemingly' correctly when I ask it to and I see the pictures in the folder from "000.jpg" to "...
1
vote
1answer
865 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 ...
1
vote
1answer
67 views

pset3 Recover - problem with final image

Hi I'm working on recover in pset3 and seems there is some problem when my code ends, can anyone point out the direction I should look into? Check50 returns the following error while all others are ...
1
vote
1answer
88 views

Pset 3 - recover. code only returns 30 images, all of which are glitchy

Some of the images returned are filled halfway, some not so much, all being glitchy colors. Not really sure what I'm doing wrong #include <stdio.h> #include <stdlib.h> #include <string....
1
vote
2answers
87 views

pset 4 - recover: undefined behavior?

I got a question regarding check50 on pset4 - recover. If i run check50 a couple times in a row, without even compiling my code in between I get different results (might be all green smileys or ...
1
vote
1answer
1k views

recover.c: expected exit code 0, not 2?

Here is the my second post regarding the same pset problem: recover.c. Running checks....... :) recover.c exists. :) recover.c compiles. :) handles lack of forensic image :( recovers 000.jpg ...
1
vote
1answer
82 views

Pset Recover: Unable to Recover JPEGs

I'm stuck on recover. My code runs and creates the files, but does it does not appear successful at recovering the pictures. #include <stdio.h> #include <stdlib.h> int main(int argc, ...
1
vote
1answer
1k views

Am I using sprintf correctly?

As suggested, I am employing sprintf to write the file names for the recover assignment. I am not sure if I am using the pointer * correctly. The documentation for sprintf shows the first argument to ...
1
vote
2answers
101 views

Pset4 recover.c compiles, but can't seem to print Jpgs at all

Am starting a new thread as I'm having trouble understanding what is wrong with the code.. I've added printf statements at the jpgCheck function and did not get a print. I suspect it's the function? ...
1
vote
1answer
41 views

recover.c encounters seg fault after 1024 bytes

In pset4, recover.c, my program finds the start of the jpegs at 1024 bytes. After that, it encounters a seg fault and I don't see why. Here's my code: #include <stdio.h> #include <stdlib.h&...
1
vote
2answers
276 views

Recover: Only finding 2 images both are correct

Have spend the last 5 hours trying to figure out what am i doing wrong with my code, I seem to fail to understand what the mistake is in my logic, I am getting just 2 images as 000.jpg and 001.jpg ...
1
vote
2answers
1k views

pset4 recover: last image not recovered correctly

My program does return all 50 jpegs, check50 says that the last file is not recovered correctly. Unfortunately, I have no idea of why - I check for the end of the file before reading new data into the ...
1
vote
2answers
529 views

pset4 recover issue-blank pics?

I was wondering if anyone could give me some guidance on this problem. I have the below code. When it runs, I see 000.jpg to 049.jpg, however all the pictures are black boxes? I'm not quite sure what'...
1
vote
1answer
175 views

pset4, recover.c: difference between two sets of fread() parameters

At first I could not get fread() to read anything from card.raw, but then I made a change to the second and third arguments, and the function worked. Although intuition led me to the change, the two ...
1
vote
2answers
596 views

pset 4 Recover: how to validate the 4 bits in the 4th byte in JPG signature?

I started this course in 2015 and it is great. It is taking a while to work through it and loving the challenge. For Recover in pset 4, my code works for finding and matching the first 3 static ...
1
vote
1answer
215 views

When I run my Recover program, it only recovers 3 of the images

Here is my code for recover.c. It compiles and runs fine, but can only retrieve three out of the sixteen images. I'm not quite sure why it does this. // Sorry about the formatting of the top part! ...
1
vote
1answer
896 views

pset4 recover works correctly but fails check50

Morning, I have just finished pset4 recover. The program works correctly and I can see all 16 jpgs and they are labeled correctly however check50 is failing:- jharvard@appliance (~/Dropbox/CS50/...
1
vote
1answer
895 views

Correct use of fopen, fclose, file pointers

I found this problem while working on recover.c. My program recovers all the image files, check50 says everything's cool, but when I run Valgrind, it gives me a ton of errors. After some tests, I ...

1
2 3 4 5
18