Skip to main content
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
Results tagged with
Search options answers only not deleted user 4847

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.

0 votes
Accepted

What is the return value of fread when it reads slack space?

I think you're looking for a problem where none exists. ;-) fread() returns the total number of elements successfully read. This maps to the third parameter in the call. Ideally, it will be the same …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

check50 says program isn't free of memory errors while valgrind says no memory leak is possi...

/recover card.raw ==21722== Memcheck, a memory error detector ==21722== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==21722== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright … /recover card.raw ==21722== ==21722== Invalid write of size 1 ==21722== at 0x4A0998E: __vsprintf_internal (iovsprintf.c:97) ==21722== by 0x49E8927: sprintf (sprintf.c:30) ==21722== by 0x1092E5 …
Cliff B's user avatar
  • 69.3k
1 vote

pset 4 recover program error

Not hard to figure out. You have free(filename); inside your while loop. On the second pass, it will try to free filename after it's already been freed. Instant error. You don't have to free filename …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

Pset 4 Recover - Unable to read card.raw -fread issue?

The immediate problem is that the return and fclose statements at the end of the program are contained within the while loop. As a result, the program exits when it hits the return statement and the …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

Recover PSET 4 Week 4 - skipping while loop

First of all, are you sure that you remembered to recompile/make a new executable from the new source code file? The while loops are working fine. When I test the code, it's generating the correct nu …
Cliff B's user avatar
  • 69.3k
0 votes
Accepted

CS50 PSET 4 Recover - segmentation fault and blank file

These are the kind of errors that drive programmers insane!!! Here's a really big hint. WHICH files are being checked to see if the pointer is NULL, the output file or the input file? ;-) There are …
Cliff B's user avatar
  • 69.3k
0 votes
Accepted

CS50 Recover Problem: Why does it give Segmentation fault (core dumped)

Yup, very common problem. You're probably not seeing it because you have to think carefully through all the pieces of what's happening and how those pieces all fit together to fail. All the pieces see …
Cliff B's user avatar
  • 69.3k
0 votes

i am unable to open my cs50 card.raw file

I'd be willing to bet that there is no "card.raw" file in the same directory as the executable recover file. …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

in pset4, recover, why is the first jpg found treated differently from the other jpg files?

Half of the answer lies in the program spec. All the data in the file before the first signature is garbage data to be discarded. The other half should be simple. Before using a file pointer to open …
Cliff B's user avatar
  • 69.3k
1 vote

pset 4: recover only recovers grey and black squares

Hmmm... did you check the sizes of the files that were created? Notice anything conspicuous? Interesting that the files seem to only have the very top part of the image. Questions: Where are the o …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

PSET4 Recover Successfully Generates Images But Does Not Match Correctly

The code does indeed create image files that can be opened, but many are not correct or complete. The problem is the nested if statements. if (buffer[0] == 0xff) { if (buffer[1] == 0xd8) …
Cliff B's user avatar
  • 69.3k
0 votes
Accepted

pset4 recover segmentation fault (core dumped)

Hmmm.... let's examine the indicators here. ;-) First, no files are being created. That's a big hint. Now, the seg fault occurs on line 51: fclose(img); It seg faults trying to close this file …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

Pset4 Recover getting segmentation fault but I have no idea why

This is a fairly common problem. Consider this. The problem spec says that the first part of the input file will contain garbage data that has to be discarded. That means that the very first data blo …
Cliff B's user avatar
  • 69.3k
4 votes
Accepted

Why does the 0.49 jpg file doesn't match correctly?

This is a very common problem. ;-) Think carefully about how the while loop ends. It checks to see if the EOF flag is set. If it isn't, it loops again. The problem is that the EOF flag isn't set u …
Cliff B's user avatar
  • 69.3k
0 votes

PSET4 Recover - Why do I get Segmentation Error from Check50

It's definitely seg faulting. I easily repeated the problem in my IDE. The problem is rooted in the use of the 2-d array picture[25][512]. This size limits the size of an image file to 12,800 bytes o …
Cliff B's user avatar
  • 69.3k

1
2 3 4 5
31
15 30 50 per page