2
votes
Why Doesn't fwrite overwrite previously copied data?
From this article:
One of the attributes of an open file is its file position that keeps track of where in the file the next character is to be read or written. On GNU systems, and all POSIX.1 ...
2
votes
Accepted
cs50 license memory free
The problem is that you are freeing the wrong thing entirely and doing it incorrectly. You need to free EVERYTHING you malloc, and the things you malloc are being stored in plates, p is just one of ...
2
votes
Accepted
Trouble with padding in resize
Two small problems with significant impact. First, the code calculates the output padding before calculating the output file width. This is disrupting the size of the output padding and two header ...
2
votes
Accepted
Week 4, Section : Dynamic Memory Allocation
In addition to the points made by @MARS and @NullityNull, there are advantages and disadvantages to both methods.
Allocating memory on the stack is more convenient because it automatically cleans up ...
1
vote
Accepted
Filter-more edge blue channel
your whole average computation piece at the end is incomplete and not exactly typesafe but I think you are getting lucky because only the blue values tend to skyrocket beyond the limits....
If you ...
1
vote
Accepted
Program won't compile w4 lab smiley
It would seem that you're trying to compile the wrong program. If you're trying to compile a helper.c program, it will fail because there's no main() code in the helper.c file. (The pattern of cs50 ...
1
vote
Accepted
pset4 filter-more All functions work when I test it but check50 gives error
Actually, all of the functions do something when the program runs, but they don't do their tasks correctly. Looking at the output image will show that something like what is required has been done, ...
1
vote
Accepted
Lab 4 using feof() function
The problem results from the nuance of the feof() function. The end of file flag isn't set until an attempt is made to read past the last byte of the file.
In this case, the prior fread() call will ...
1
vote
Accepted
Lab 4 volume understanding fopen() & fwrite()
First, understand the difference between write and append when opening a file for output.
If you open a file with "w", or write, it will open the file of the specified name. If it doesn't ...
1
vote
Lab4 fread() and fwrite() problem
From man fread
On success, fread() and fwrite() return the number of items read or written. This number equals the number of bytes transferred only when size is 1. If an error occurs, or the end of ...
1
vote
Accepted
CS50 blur filter failed 3x3 and 4x4
Very interesting! Did you notice that in the two failing cases, all of the pixels on the right and bottom edges are incorrect?
So, that says there's something wrong with the code that handles those ...
1
vote
Why Doesn't fwrite overwrite previously copied data?
The answer lies in how the file was opened. When opening a file with fopen (which must have been called earlier in the file), you can pass a parameter as the mode to open the file in. Some of these ...
1
vote
Accepted
Cs50 Sepia properly coded
It's very readable as it is, with little inefficiency. The only things that I can think of doing would be to delete the temp vars original(color) and use the array vars directly. That would eliminate ...
1
vote
Accepted
Pset4: Recovery- Empty JPEG files
You seem to be missing a concept. Each jpg will be made up of multiple blocks of 512B. Your goal is to read from the rawfile until you find a signature block. Once you do, if you already have found ...
1
vote
Accepted
CS50 Week 4 Recover. Generating 50 Blank images
The biggest problem here is that the code is trying to test for a signature before actually reading in the data from the input file. It's doing a "Ready, Fire, Aim." Order of actions is ...
1
vote
Accepted
CS50 Recover jpg files not found
This is the problem. You read one char from the cardfile, but this char is never processed as part of the bytes. Basically, you just drop these chars.
while((c = fgetc(cardfile)) != EOF)
{
1
vote
Accepted
WEEK4 Pointer examples does not work, i really need explanation
Printing out the address of a variable
"%x" does indeed require that the variable you are trying to print is an unsigned int, but &var1 and &var2 are both pointers (int* and char (*)[...
1
vote
Check50 doesn't accept my resize solution
Actually, the posted code is not doing many of the things that it should. If tested with rfactor == 1, it works fine, as indicated by :) doesn't resize 1x1-pixel BMP when n is 1. However, when rfactor ...
1
vote
Accepted
This code is written as per video in CS50 week 4 but it is not working
You are always using the subscript 'i'. 'i' has the value 3 when the first loop is finished. You can either change the subscript names in the y loop and the x loop OR just use 'i' again to run those ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
week4 × 34pset4 × 7
cs50x × 5
walkthroughs × 5
recover × 4
lab4 × 4
c × 3
memory × 3
resize × 2
segmentation-fault × 2
pset4filter × 2
edges × 2
compiler × 2
file × 2
file-pointer × 2
allocation × 2
volume × 2
blank-jpeg × 2
pset3 × 1
pointers × 1
pset4recover × 1
blur × 1
fails-check50-but-works × 1
help × 1
malloc × 1