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
0
votes
1answer
20 views

i have tried it with small diffs a lot of times.i feel more comfortable about this, but still not working.what am i doing wrong??thanks in advance

// creat a counter that keepw trach of jpegs found int counter = 0; // crate a string filename for sprintf char filename[8]; // FILE* picture = NULL; // chech if we have found ...
0
votes
1answer
50 views

Pset 4--51 files created instead of 50

Apologies for including all my (60 lines) of code, but I've been thoroughly confused by this for a while. I've written code to do Recover, and it's working fine and recovers images perfectly--it just ...
0
votes
1answer
36 views

pset4: check50 say that recover.c compiled with an exit code of 1 and not 0

I completed my code and it recovers all images fine. However, when I ran check50 for recover, I received this error code with a domino effect on the rest of them: https://legacy.cs50.me/checks/...
0
votes
1answer
106 views

What's wrong with this recover code?

I wrote some code for recover that seems to me to be recovering the image correctly (I can see pictures of people for all 50 images), but for some reason, check50 says that 049.jpg does not match the ...
0
votes
1answer
54 views

jpg's are not proper, mix of multiple images. Can anyone tell me whats wrong?“RECOVER”

here is my code while (fread(buffer, 512, 1, inptr) == 1) { if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && (buffer[3] & 0xf0) == 0xe0) ...
0
votes
1answer
52 views

PSET3 Recover - Creating only textfiles for .JPG not images

My version of Recover for pset3 is creating 50 .jpg files but only as textfiles not images and I can't work out why. I've looked through this forum and saw one similar question but the issue ...
0
votes
1answer
63 views

PSET3 Recover: My code works when I make the buffer an array, but not when I use malloc

My code works perfectly when I make the buffer I use in fread and fwrite an array of unsigned chars, but when I use malloc to allocate memory space I get segmentation faults (this is the opposite of ...
0
votes
1answer
37 views

Pset4 recover.c fwrite if header is not found but already found the first jpeg

Can someone explain to me, why will there be a case where the first jpeg has already been found but subsequent jpeg doesn’t match the header? I thought all jpegs should match the header? If (...
0
votes
1answer
76 views

pset4 recover - doesn`t recover all files

Struggling with recover at this moment. My code creates just 8 pictures out of 50 - from 2nd to 9th. Other jpegs are also made but i am unable to see them due to "Invalid or Unsupported Image Format". ...
0
votes
1answer
22 views

Fread doesn't return new values to buffer - recover - pset4

I am currently working with recover and when I first compiled my program with debug50, my program was able to return 6 corrupted files without a propre name. When I wanted to get a closer look as to ...
0
votes
1answer
65 views

pset3 recover, only get 49 jpgs and all are wrong by check50, but look correctly

I recently started with CS50 and I struggle a bit with pset3's recover. While the jpgs look correct to me, my code only recovers 49 jpgs total, not the 50 which are expected. Check50 fails on the ...
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 ...
0
votes
1answer
49 views

Need help with recover

I have been working with recover for a long time and I have a great problem with detecting the beginning of a JPEG. I have tried for a long time to no avail. I feel my problem may be with buffer but ...
0
votes
2answers
94 views

Pset3 recover __ How can I read and store data from card.raw to an array, and print this data-array byte by byte?

(This is the 1st time I use this site) I've tried many different ways, and all failed. Mostly 0s are being printed. Any idea how to approach this? I've spent the entire week on this already. Actually,...
0
votes
1answer
132 views

problem with recover.c using malloc and fread

i tried to write a function that sample 4 bytes from card.raw file but i doesn't work because fread doesn't put any data into block buffer so i wrote this simple code and i found out that fgetc works ...
0
votes
1answer
68 views

CS50 Recover image does not match

I have been working on this problem for a while but could never get it to work. Check50 says that the recovered image does not match. When I opened the recovered images manually, they are all blank. I ...
0
votes
1answer
96 views

Recovered image does not match pset3

I can't figure out what is wrong with my code. I recovered images from 000.jpg to 050.jpg. This is my code #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef ...
0
votes
1answer
254 views

Recover.c; Need explanation about how to implement “write 512 bytes until the new jpeg is found”?

I am completely stuck right now when it comes to implement: Write 512 bytes until the new jpeg is found. Could anyone give me idea how to implement this step? Here is my code: // Declare ...
0
votes
1answer
32 views

cs50 Recover segmenation fault

I am working on the CS50 Recover Problem and got stuck on the segmentation fault. #include <cs50.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { ...
0
votes
1answer
54 views

recover.c producing random image 🙁

recover.c is always producing this image: Here is my code: #include <stdio.h> #include <stdint.h> typedef enum {false, true} bool; // Bool int main(int argc, char *argv[]) { if (...
0
votes
0answers
39 views

recover.c spits out images that are partially recognizable

recover.c compiles and runs normally, but it produces 21 images that have chunks of different images mixed in. Here are the images: 000.jpg: 001.jpg: 002.jpg: 003.jpg: 004.jpg: Because I'm too ...
0
votes
1answer
51 views

pset3 recover is fopen changing the first value in my buffer?

My code for pset3 works and recovers all the images as it is supposed to however I realised that when I call fopen the first value in my buffer array becomes 0 I fixed this by changing the value back ...
0
votes
1answer
48 views

CS50 recover - images are some kind of blank

//My program creates images of different sizes but without content (just black and white pixels). Someone can help me? #include <cs50.h> #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
56 views

All 50 images look good but failing on middle images on check50 “:( recovers middle images correctly recovered image does not match”

I thought I was there, I was failing on the last image not matching also, but after looking through similar questions I realised that I was checking for EOF before the read of the raw file and not ...
0
votes
1answer
101 views

recover.c:43:34: error: use of undeclared identifier 'out' fwrite(temp, 1, 512, out);: WHAT?

When I compile my program, clang is probably not working. I get this when I compile: ~/pset3/recover/ $ make recover clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -...
0
votes
1answer
53 views

Pset4 - Recover - Segmentation fault when trying to free buffer

I have run the debug50 and it seems the seg fault occurs after trying to free memory here: // if not start of a new jpeg and we HAVE NOT already found one before if (block_buffer[0] != 0xff &&...
0
votes
1answer
132 views

PSET 4 recover doesn't pass check50 - “recovered images do not match”

All images are recovered, and when I open them, they all display correctly (I checked every one of them in the IDE), yet my program is not passing check50. Why? Here's my code: #include <stdio.h&...
0
votes
1answer
65 views

cs50 Recover — Segmentation fault and too many jpegs

I'm stuck with the debugging the below code. I keep getting way too many jpg files written and a segmentation fault. Thanks in advance for the help. I'm new to programming and this one is kicking ...
0
votes
1answer
42 views

Pset4: Recover - Reach EOF to “early” aka. doesn't recognize beginning of new jpg

I am fighting with the recover challenge in pset4. Had some progress and was able to detect 20 images. But then my condition for finding EOF is true and the program stops. I think the problem is, ...
1
vote
1answer
192 views

pset3 recover not sure how the code works

I'm taking baby steps towards writing the code for recover. So far I have written this: int count = 0; int blocks = 0; // Loops through the whole card. while (feof(card_in) == 0) { // declares ...
0
votes
1answer
152 views

Pset4 - recover, unable to pass check50

#include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[1]) { // ensure the arguments are correct if (argc != 2) { fprintf(stderr, "Usage: ./recover filename\n"...
0
votes
1answer
88 views

Why can I recover only two images?

This is my code for pset3, recover #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { // ensure proper usage if (argc != 2) { fprintf(stderr, "...
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....
0
votes
1answer
136 views

Pset 3 Recover : segmentation fault for “already found JPEG” loop

I'm having some difficulties understanding the flow of recover. I've used the code and have written the pseudocode like this: if the start of a JPEG file is found - if it is first JPEG, create new ...
1
vote
3answers
6k views

cs50. pset4. recover

I ask for help. I do not find the error. I prompted and rewritten the code. Next is a new version, but the cs50 does not pass! The files have been resumed. performance control does not pass list of ...
0
votes
1answer
77 views

problem with checking 4 bytes of jpeg

So i recently completer recover and it came out that the only problem was with the code that was actually told in the recover walkthrough about the checking of jpeg 4 bytes.The code was: if(block[0]...
0
votes
2answers
255 views

Pset 3 (Recover): Why are images still glitchy?

I've been having trouble with pset3's Recover exercise. My code successfully compiles and creates 50 jpegs, numbered 000 to 049. However, all images are terribly glitchy. Examples: I've scoured the ...
0
votes
2answers
90 views

pset3 recover output not valid ASCII text

I'm recovering all 50 JPEG images, but still failing check50 with the message: "output not valid ASCII text." Not sure if this might have something to do with it, but for some reason, my buffer[0] ...
0
votes
1answer
109 views

Recover.c Help?

I wrote a code for recover.c, and though it compiles, it doesn't function properly. I don't know specifically where the issue is, (it could be the entire concept, really) but I'm sure the fread() and ...
0
votes
1answer
100 views

PSET4 RECOVER (QUESTIONS)

I managed to make my code recover all 50 images, and have passed check50. However, during the development process I have encountered two problems, and still doesn't get why it is an issue. Here is my ...
0
votes
1answer
103 views

PSET4 Recover spits out 50 images but they're all invalid

#include <stdio.h> #include <stdint.h> #include <stdlib.h> #define FAT_BLOCK_SIZE 512 // I figured out how to get block size from here "https://cs50.stackexchange.com/...
0
votes
1answer
42 views

Pset4 recover: my code never recognises the beginning of a jpeg

When I compile the code I don't get any errors, however when I run it i get a segmentation fault. I discovered this is because my code never finds the beginning of a jpeg so my img file never gets ...
0
votes
1answer
61 views

PSET 4 RECOVER - My program outputs 50 images however they all have an invalid format

So I think I've nearly finished but I've come upon a bit of roadblock. That is all my photo are invalid. I looked at all the threads I could and couldn't find out why. My Code: #include <stdio.h&...
0
votes
1answer
74 views

PSET4 Recover Output Ptr Closing/JPEG Writing

I have a script that mostly works, I think, but I cant get the file writing to work. I have seen some others use a flag for calling when to close the output pointer but I cant see why this way wont ...
0
votes
1answer
52 views

Pset4 Recover - Program only recovers 2 images, but loops 50 times

My recover.c program only recovers 2 images, although when I tested how many loops it did, it did 50. Both images recovered seem complete, nothing weird about the images. Check50 also confirmed the ...
0
votes
2answers
222 views

PSET4, Recover - Generated JPGs are blank

My code compiles and saves 50 JPG images with proper names, but when I try to open any one of them, all of them are blank, just grid. When I run check50, I get Segmentation fault error. What I'm ...
0
votes
1answer
63 views

Can't open generated JPGs

My code compiles and saves 50 JPG images with proper names, but when I try to open any one of them, I get the 'Invalid or Unsupported Image Format' error. What I'm doing wrong? Here is pseudo-code: -...
0
votes
1answer
183 views

pset4 recover - my implementation recovers 50 jpegs but check50 rejects

I am having trouble with recover from pset4 - when I run it, it creates 50 images, apparently correctly formatted (000.jpg-049.jpg). However, check50 rejects it: :) recover.c exists. :) recover.c ...
0
votes
2answers
230 views

PSET 4 - Recover: recovers JPGs but doesn't pass check50

My implementation of Recover produces 50 JPGs but does not pass check50. I am stumped. Any help would be greatly appreciated. #include <stdio.h> #include <stdlib.h> #include <stdlib.h&...
0
votes
1answer
48 views

pset4 recover file name declaration

char jpgname[8]; // Correct declaration char *jpgname = "000.jpg"; // Incorrect declaration . . sprintf(jpgname,"%03i.jpg", fileNum); // Segmentation fault seemed to occur on this line if the ...

1
3 4
5
6 7
18