Questions tagged [pset4recover]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
1answer
2k views

If I use fread in a while loop, will it move the file pointer?

I am doing pset4 recover.c and have a bit of confusion.. Does this move the pointer? while(fread(buffer,1,512,card) == 512){ rewind(); // do I need to rewind? or just write what's in buffer? }
1
vote
1answer
24 views

pset 4 - recover, can't figure out mistake

I can't figure out what I'm doing wrong, please help! #include <cs50.h> #include <stdio.h> #include <stdlib.h> #define BUFFER_SIZE 512 int main(void) { // open memory ...
1
vote
1answer
165 views

PSET4 Recover produces JPGs, but passes CS50 check only partially

My PSET 4 Recover code is able to recover the 50 jpg's from the raw file. However, when checking the code with the check50 it only partially passes. I checked a lot other related issues on SE CS50 ...
1
vote
1answer
660 views

Pset4 recover using fread as condition

In the walkthrough Zamyla mentions using fread as a condition. I've tried using it as the while condition, hoping the loop would stop when fread returns 0 but I get only 26 heavily distorted jpegs ...
1
vote
2answers
44 views

Major Help Needed on CS50 - Recover

I would love any possible help with this code. I think I've got the general idea, but I keep running into segmentation faults. Thank you to anyone who gets a chance to look this over! I've been very ...
1
vote
1answer
21 views

CS50 recover (fclose giving segmentation fault)

found a few answers to the segmentation fault issue in CS50 recover while closing the file but I couldn't translate the answers to my issue: The last part: fclose(f); fclose(img); is resulting into ...
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
252 views

Recover pset 4 last image

I have been working on this for a long time. I used check50 on it and it reports that the last image isn't recovered correctly. Can someone provide insight? #include <stdio.h> #include &...
0
votes
1answer
131 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
45 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
22 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
1answer
74 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
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
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
173 views

recover pset4 file handling

I got this code to work, but I have a few questions for my own clarification. On line 68 where I define the jpg title, why is it a single character? The actual title 001.jpg is much longer than a ...
0
votes
1answer
97 views

PSet4 recover: recovered files start with a wrong sequence

My recover program creates 50 files, but they do not open (it says "Invalid or Unsupported Image Format"). I opened some of the JPEGs with a hexadecimal editor and found out that they start with 00 d8 ...
0
votes
1answer
110 views

pset4 recover.c Why are my pictures scrambled?

My attempt at recover.c almost works. It creates 50 jpegs and names them appropriately. And it fills them part way before getting scrambled. Here is an example: Here is my code: #include <stdio....
0
votes
2answers
40 views

Pset4 recover- cannot open file for writing error

#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc!=2) { fprintf(stderr, "./recover nameofimagefile\n"); return 1; } char *...
0
votes
1answer
133 views

PSET4 Recover Can't Open JPEGs in the IDE

I've recovered all 50 JPEGs and when I download them to my computer and change the name from (for example) 000.jpg%OA I can see the picture correctly. However, in the IDE,if I open the same JPEG I get ...
0
votes
1answer
22 views

Recover.c - Code Creates JPG files but it doesn't doesn't match expected output

#include <stdio.h> #include <stdint.h> #include <stdlib.h> typedef uint8_t BYTE; int main(int argc, char *argv[]) { //user didn't enter one argument or enters more than one if (argc &...
0
votes
1answer
19 views

not recovering any JPEGs though the code works

can someone tell me what is wrong with my code it works and recovers but no images are found upon checking :) recover.c exists. :) recover.c compiles. :) handles lack of forensic image :( recovers 000....
0
votes
1answer
38 views

PSET 4 Recover.c - Segmentation fault

The code compiles perfectly. However, it triggers a segmentation fault which I imagine is due to a wrong use of pointers. This is the code: #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
13 views

Why is my recover code not giving any output?

I'm very confused why this code is not giving any output: Code: #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef uint8_t BYTE; long int findSize(char file_name[]) ...
0
votes
1answer
34 views

pset4 recover: Not getting as many files as the problem requires

After reading a few submissions for help here and in the subreddit, People have told me there should be 50 files in the memory card. I have made a loop that correctly reads the file, but as soon as I ...
0
votes
1answer
36 views

Pset4 Recovery Produces Corrupt Null Files & Skips An Image

I've been working at recovery for a while - I believe I'm nearly done with it - but right now my code is giving me serious problems. Currently, running ./recover card.raw produces 49 of the 50 images (...
0
votes
1answer
45 views

pset 4 - recover. Can't figure out what is going wrong!

Can't figure out what I'm doing wrong, I've spent like 2 days on it already, please help! #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc != 2) {...
0
votes
1answer
24 views

Pset4 Recover Segmentation Fault Issue

I'm having an issue with my code, and I was hoping you could help! I keep getting a segmentation fault error, and I'm not sure why. I've ran valgrind and according to its findings, the issue seems to ...
0
votes
1answer
46 views

Stuck on recover

I am currently stuck on recover and cannot understand the fread function and how does it behave. I have watched all the shorts and explanations but i still don't get it. I also wasn't able to find any ...
0
votes
1answer
50 views

Pset4 Recover - Unexpected Output

My program outputs JPEG files, but not enough and they are corrupted. It has been a long day and it is Friday. Any kind of push in the right direction would be fantastic thank you. #include <stdio....
0
votes
2answers
46 views

Incompatible pointer types passing BYTE to FILE

#include <stdio.h> #include <stdlib.h> #include <stdint.h> //Define BYTE typedef uint8_t BYTE; int main(int argc, char *argv[]) {//Check if command line is correct// if (argc != ...
0
votes
1answer
37 views

Code only detects one jpeg in pset4 recover problem

my code for pset4 recovery only detects one jpeg signature. Here's my code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <...
0
votes
1answer
37 views

Pset 4 Recover - Middle Images Don't Recover Correctly

When I run recover, most of the pictures get recovered correctly (first and last are correct), but some in the middle don't for some reason. Any ideas why? Any help would be appreciated. #include <...
0
votes
1answer
305 views

(pset4) Fatal error: glibc detected an invalid stdio handle

everyone! I've been stuck with this one for a little while. Through debugging I found out that my problem is probably in the size parameter I'm trying to pass to fread() in line 33 (start of the while ...
0
votes
1answer
64 views

Recovers images, but Check50 is not happy!

I have successfully (or I guess not super successfully) recovers all 50 images, but where am I going wrong? Thanks! #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[])...
0
votes
2answers
49 views

CS50 pset 4 recover, only two images recovered

I am currently working on pset4 recover.c. My code complies correctly, but when I run it, only two files are outputted (000.jpg & 001.jpg), which I believe there should be 50 files. I'm not sure ...
0
votes
2answers
57 views

Can't write jpegs in recover, segmentation fault

here's the code i wrote: #include <stdio.h> #include <stdint.h> #include <stdlib.h> typedef uint8_t BYTE; //take command line argument from the user for the file name int main(int ...
0
votes
1answer
31 views

pset 4 - recover, almost done! images opens correctly but check 50 doesn´t recognize it

My programs seems to work nicely,i can even see the images, i just don´t get what´s going on with Check50, must be a tiny detail. Thank you. Here is check50 : https://submit.cs50.io/check50/...
0
votes
1answer
93 views

Pset4/recover: code is working fine but the recoverd images are not correct

I have written this code. The code seems to work fine but the images are not correct they are distorted. I have attached those photos below. Can you please help me and tell me where I went wrong in ...
0
votes
1answer
64 views

pset4 recover: 'recovered image does not match'

My program recovers the images but the recovered images are all blank and check50 says that they "don't match". All the images are 512 bytes in size. Please help me find out why this is happening. My ...
0
votes
1answer
64 views

pset4 recover 049.jpg recovered image does not match

I cant understand why 049.jpg is not working #include <stdio.h> #include <stdlib.h> #include <stdint.h> unsigned char bytes[512]; //counter for the jpg files int jpgCount = 0; ...
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
20 views

can anybody check what wrong with code. in recover. it does not crete any file(jpegs) while running. please help me

#include <stdio.h> #include <stdint.h> #include <cs50.h> typedef uint8_t BYTE; int main (int argc , char* argv[] ) { //ensure correct usage in terminal if (argc!=2) {...
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
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
1answer
110 views

PSet 4 Recover works, but returns 1, not 0. HELP!

My recover program works and spits out 50 JPEGs, but when I run it through check50 I receive the message: :( recover.c compiles. expected exit code 0, not 1 I have used the debugger to the ...
0
votes
1answer
38 views

pset4 recover - jpgs in place, 0 is returned, but Check50 fails - segfault

My "recovery" programm works - all 50 jpg files are recovered and pictures are visible. The programm terminates with returned 0. But as I run check50 it tells ":( recovers 000.jpg correctly - failed ...
0
votes
1answer
22 views

PSET 4 - RECOVER

I have look at my code for a while now and for the life of me cannot find the bug. When run, I am able to recover JPG's however only the upper left most portion reveals the picture, with the rest ...
0
votes
1answer
124 views

pset4 recover single image

My recover program currently successfully returns a single image "001.jpg" which looks good when I open the file. It also returns a second image "002.jpg" which prompts an error for an Unsupported or ...
0
votes
1answer
78 views

Problem Set 4 Recover Issues. I can't figure out why my code doesn't work

I'm busy with problem set 4, and I can't figure out why my code doesn't work. What seems odd is that the first line or two of a new jpeg will seem partially or fully correct, but thereafter the images ...
0
votes
1answer
27 views

How to solve the segmentation fault in pset4 recover?

While using debug50 to check my code, I realized that it would encounter segmentation fault when it reaches "fwrite(buffer, 512, 1, photo);" for the second time. There's no problem on the first time ...