Skip to main content
2 votes
Accepted

Pset4 - recover - issue with file pointers

Yup, it's all about scope. Since the file pointers are being declared inside the IF code blocks, they cease to exist when processing leaves those code blocks. Remember, a variable only exists within ...
Cliff B's user avatar
  • 69.1k
2 votes
Accepted

Understanding the contents of the raw file

It looks like gibberish because the code is printing it as if it were ASCII char data. In reality, it is literally raw digital data. It doesn't translate to ASCII codes or anything else. Instead, it ...
Cliff B's user avatar
  • 69.1k
1 vote

reverse .wav file not working correctly

Ok I found it, I just had to say: while (ftell(input) >= sizeof(header)) instead of while (ftell(input) > sizeof(header))
Ahmed ElToukhy's user avatar
1 vote
Accepted

(PSET 4 - Recover) Why is first recovered image blank?

So, the first file is bad. That should be a clue that there's something wrong with how the first file is processed. Did you step through the program using debug50 and watch which statements execute? ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

pset4 - Recover passed check50, but want to understand the logic on fwrite or file-pointer

First, when your program reaches line 74, you already have a file open that has it's location stored in a pointer you named img. When your program goes to write to this, it does not try to reopen it ...
Robert S. Pratt's user avatar
1 vote
Accepted

Why does `size` = `0` occur?

The code is working correctly. If it's giving a file size of 0, the file size really is zero. Maybe it was overwritten? If the file weren't there, it would gen an error. Why are you getting a file ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

Can't write jpegs in recover, segmentation fault

The first problem is that you need to learn how to find the line causing the seg fault. Simply guessing where the problem isn't an effective way to debug a program. Please read my answer to another ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

What does a pointer to a file really represent?

A FILE pointer is a pointer to a struct. That struct contains numerous elements. (You'll learn about structs later, if you haven't already.) This particular struct is defined in stdio.h as follows: ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

pset4 resize: setting bfSize and biSizeImage hexadecimal values

Well, that's an unusual way to try and do that. You're writing to the headers in the file! Seems like the hard way to update the headers. Don't you think it would be easy to read the headers into a ...
Cliff B's user avatar
  • 69.1k

Only top scored, non community-wiki answers of a minimum length are eligible