Skip to main content
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 ...
DinoCoderSaurus's user avatar
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 ...
UpAndAdam's user avatar
  • 1,426
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 ...
Cliff B's user avatar
  • 69k
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 ...
hotwebmatter's user avatar
  • 3,050
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 ...
UpAndAdam's user avatar
  • 1,426
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 ...
Cliff B's user avatar
  • 69k
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, ...
Cliff B's user avatar
  • 69k
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 ...
Cliff B's user avatar
  • 69k
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 ...
Cliff B's user avatar
  • 69k
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 ...
DinoCoderSaurus's user avatar
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 ...
Cliff B's user avatar
  • 69k
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 ...
Robert S. Pratt's user avatar
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 ...
Cliff B's user avatar
  • 69k
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 ...
curiouskiwi's user avatar
  • 18.7k
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 ...
Cliff B's user avatar
  • 69k
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) {
stensal's user avatar
  • 450
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 (*)[...
chad's user avatar
  • 239
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 ...
Cliff B's user avatar
  • 69k
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 ...
DinoCoderSaurus's user avatar

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