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
569 views

Pset4 recover: Images are invalid or unsupported format

I dont get why all of my jpeg's appear but they are all invalid. When i try to open them none of them opens and gives "invalid or unsupported Image format" error.Can someone help me to spot what am i ...
0
votes
1answer
453 views

Need clarity in setting up buffer in recover

I can't seem to wrap my head in the code below. unit8_t BYTE; Does this create a data type the size of 8 bytes? But don't I need 512 bytes for the buffer? BYTE buffer[512]; Does this create an ...
0
votes
1answer
129 views

Recover: all 50 JPGs have “0” as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 50 jpgs but none of them show. When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature. But byte ...
0
votes
1answer
448 views

Recover Segmentation Fault

I have been struggling with recover in pset4. The program compiles and it seems like the code should work, but I get one .jpg file with no information in it. I also get a segmentation fault. I've ...
0
votes
2answers
144 views

recover function causes segmentation fault

I've finished writing the recover function and made it to compile successfully. However, it gives out a segmentation fault every time I try to run it. I ran valgrind and the error was in the first if ...
0
votes
2answers
35 views

Why does my code lead to segmentation fault [CS50 recover.c]

#include <stdio.h> #include <stdlib.h> #include <cs50.h> int main(int argc, char *argv[]) { if (argc != 2) { printf("./recover file_name\n"); ...
0
votes
3answers
110 views

Pset4 recover: Images recovered but check50 failed

I am currently stuck on this problem set, as it seems like I am able to recover the 50 jpgs but I am failing the check50. I am not sure what I am doing wrong and would appreciate some help. :( ...
0
votes
1answer
151 views

PSet4 Recover, only finds 22 corrupted photos, doesn't pass Check50

Originally, my code always returned Segmentation Faults whenever running it. I used printf statements to find and fix the segmentation faults, but now it is only finding 22 out of the 50 photos and ...
0
votes
1answer
128 views

Pset4 Recover conceptually struggling

Pset4 Recover is different since it uses files; fopen, fcloser, fprintf, and fread. It adds a whole new dimension to the coding. Its change from just formatting conceptions to making sure all the ...
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
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
113 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
97 views

Recover.c does nothing

Recover.c I have written code of recover.c of pset4. Every time I compile it, everything seems fine but when I run it using: ./recover card.raw, I get a new line with no files created. Why is this? ...
0
votes
2answers
216 views

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

so this is my second time posting about this pset, my code is below. No images will open, with the current code. However when I do get something to open it is just 1 file and it says invalid or ...
0
votes
1answer
1k views

Pset4 - Recover (usage of sprintf)

When I am working on Pset4 - Recover, I realize I do not understand the concept of array and pointer. Although I finally worked it out, I would be very grateful if you guys can explain the following: ...
0
votes
1answer
860 views

recover.c Invalid or Unsupported Image Format

I wrote the code that logically I think should be working, it creates 50 images, however if I try to open any of them, it says Invalid or Unsupported Image Format also when I tested it with ...
0
votes
3answers
158 views

The Check50 of recover Pset4 throws error but it works

The Check50 of recover Pset4 throws error but it works. Help! It gets all the 50 images. #define JPGREAD 512 int main(void) { // open input file FILE* inptr = fopen("card.raw", "r"); ...
0
votes
1answer
121 views

pset4 recover check50 killed by server

I've made a program that outputs 50 viewable jpegs and names them 000.jpg through to 049.jpg but I am not passing check50, here's what the tests say: This is what valgrind returns: HEAP SUMMARY: ==...
0
votes
1answer
241 views

pset4 recover.c Segmentation fault

I have a segmentation fault that I can't figure out. Can you please help me? It has been 4 days and I have no idea what to fix. Thank-you Here is my code: #include <stdio.h> #include <...
0
votes
2answers
237 views

cs50 Prblem set 4 recover. Can someone please look at my code and tell me why I'm getting a segmentation fault?

/** * recover.c * * Computer Science 50 * Problem Set 4 * * Recovers JPEGs from a forensic image. */ include include include int main(int argc, char* argv[]) { // Ensure proper usage ...
0
votes
1answer
2k views

recover.c how to find beginning of next jpeg

So far, I have managed to find the byte-sequence that a block in the .jpeg file starts with. Now I don't know how to tell the program to stop at the next such block. Moreover, I don't know how I ...
0
votes
2answers
416 views

Developing JPEGS for pset4's recover troubleshooting

I am currently working on cs50's pset4 recover. I have managed to compile the program. However, when run, the images are corrupt and apparently, according to image viewer, are not jpeg files, because ...
0
votes
1answer
348 views

How do I add leading zeros to the filename in `recover`?

I wrote a perfectly functional recover.c program yesterday. But I can't get the file naming right. How can I add leading zeroes to the file name so the name is 000 instead of just 0?
0
votes
1answer
34 views

My recover doesn't stop executing once it starts

Not actually sure what is wrong with my code but it doesn't end when it's executed. I tried adding return 0 so it would end but it's not working. code: #include <stdio.h> #include <stdlib.h&...
0
votes
2answers
51 views

CS50 Recover (Pset4). What exactly is causing the segmentation fault?

CS50 NEWBIE here. Program successfully compiles but I keep getting a segmentation fault error when trying to run it. After some debugging, I think the problem has something to do with trying to close ...
0
votes
1answer
51 views

PSET4 Recover: Check50 shows error

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> typedef char* string; typedef uint8_t BYTE; int main(int argc, char *argv[]) { if (argc != 2) { ...
0
votes
1answer
21 views

check50 on recover pset 4 saying this what am i doing wrong

:) recover.c exists. :) recover.c compiles. :( handles lack of forensic image expected exit code 1, not 0 :) recovers 000.jpg correctly :) recovers middle images correctly :) recovers 049.jpg ...
0
votes
1answer
43 views

I know that my recover is wrong, but I'm not sure what steps to take-

I 'm getting a segmentation fault for my recover code. I know that it's wrong, and I think that this boils down to me not really understanding how to apply pointers/file functions. Maybe you could ...
0
votes
1answer
72 views

Pset4 - recover - issue with file pointers

I'm working on recover and I think I'm nearly there but I can't resolve an issue with file pointers. When I'm compiling I'm getting two errors both say error: use of undeclared identifier 'ptr'. I ...
0
votes
1answer
93 views

Can't seem to wrap my head around what the Bitwise AND operator does in Pset4 vs. && AND operator

I just watched the Recover video and I saw them mention bitwise arithmetic, but I am not exactly sure what that means nor what it does. I saw another forum post explain it but that also didn't really ...
0
votes
2answers
32 views

Valgrind - 2 memory leaks | Recover.c | Pset-4

Valgrind encountered two errors in the following code. I'm not able to get why is this happening even when I close files and free allocs. Please help if you can. #include <stdio.h> #include <...
0
votes
1answer
23 views

Understanding the contents of the raw file

I'm playing around with file pointers in preparation for the Recover Problem. I'm trying to understand something here. I can't actually open up the raw file to read on my IDE. And neither can I read ...
0
votes
2answers
53 views

Issues with PSET4 recover (recover.c), can't create jpg's (segmentation fault)

Can't seem to find what is happening with my code, please help! I've been stuck in this problem for way too long. The jpg's are not created when I run the code. #include <stdio.h> #include <...
0
votes
1answer
75 views

Week 4 recover segmentation fault

I have spent two evenings on recover but I just can not figure it out. For the first time I managed to recover everything but the first image without any problems, so I did some searching and ...
0
votes
1answer
90 views

Pset 4 - Fopen returns NULL

Currently working on the Pset4 recover.c assignment. My code compiles correctly, however, when I execute, fopen return NULL. Based on my understanding from the shorts on file pointer and the lecture, ...
0
votes
1answer
59 views

pset4 Recover - need to break (^C) to exit

I'm recovering the files just fine, but my program seems stuck in the while loop. I've tried adding extra closing statements and adding else statements, but I can't seem to find where/why it won't ...
0
votes
1answer
84 views

Having trouble getting recover off the ground

I'm sorry to do this but I'm fairly lost with this pset3 recover for cs50. I've been researching for hours and am no closer to figuring out how to utilize FILE *outptr = fopen and sprintf(filename, "%...
0
votes
1answer
69 views

Pset4 - Recover: Weird output

This problem set is the worst and it made me cry 🤣 Take a look at this code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { // ...
0
votes
1answer
229 views

Not Recovering the last “Recover” image

Having an incredibly tough time figuring out where my error is. The JPEG outputs look good but when I do check 50, I'm getting a :( for "recovers 049.jpg correctly - recovered image does not match....
0
votes
1answer
143 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
268 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
45 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, ...
0
votes
1answer
86 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
257 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
1answer
105 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
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
187 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
235 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
67 views

pset 4 recover still getting memory leaks

I've been told before that my code is getting memory leaks (when running Valgrind this becomes apparent) so I now free memory at the end of the program, but I'm still getting leaks. Even beyond ...
0
votes
1answer
59 views

Code runs, but no JPEGs are formed in recover

#include <stdio.h> #include <stdlib.h> #include <cs50.h> int main(int argc, char *argv[]) { // ensure proper usage if (argc != 2) { fprintf(stderr, "The program ...

1 2
3
4 5
18