Skip to main content

Questions tagged [pset4]

The standard edition of Problem Set 4 will move beyond C programming language basics, testing your knowledge of pointers, memory management, file i/o and structs.

Filter by
Sorted by
Tagged with
10 votes
3 answers
1k views

pset4 speller - can't pass valgrind test - 32 bytes still reachable

Can't pass valgrind test on pset4 speller (hashtable). The speller works perfectly but, I'm getting this message from valgrind: ==3911== ==3911== HEAP SUMMARY: ==3911== in use at exit: 32 bytes ...
agraffe's user avatar
  • 101
1 vote
1 answer
2k views

What is the difference in behavior between fread and feof?

For pset4's recover.c code, I noticed the following: when I set my while loop to be while (!feof(inptr)), all the images get recovered, including the last, but check50 throws an error (TODO) when ...
Richard's user avatar
  • 166
0 votes
2 answers
429 views

Developing JPEGS for pset4's recover troubleshooting

I am currently working on cs50's pset4 recover. I have managed to compile the program. However, when run, the images are corrupt and apparently, according to image viewer, are not jpeg files, because ...
AWATHIEU's user avatar
4 votes
4 answers
1k views

Running breakout on Mac OS X

There's a similar question about running breakout on Linux variants: Can't run Breakout outside of appliance My question is specifically about compiling breakout (and hence SPL) on Mac OS X. So ...
Luke Van In's user avatar
  • 2,655
2 votes
1 answer
4k views

Pset4 resize.c - bfsize & bisizeimage formulas

First of all thanks for your time. Taking cs50 through edX - struggling as all alone here and videos / lectures are burnt out for information - need real people! Online cs50 really does assume a lot ...
KrisValentine's user avatar
1 vote
4 answers
1k views

check50 gives confusing results for pset4 resize

FOR CS50 STAFF ACTION: When I ran check50 against resize, I got a very confusing result. I've seen that others have seen the exact same result. Here's the problem - the output is giving negative ...
Cliff B's user avatar
  • 69k
2 votes
2 answers
747 views

Pset4 recover, comparing hex in if statements

I'm trying to solve "recover" but, I'm unable to compare my if statements. This is my error message: error: comparison of constant 224 with expression of type 'char' is always false [-...
olafironfoot's user avatar
1 vote
1 answer
209 views

Pset4 recover: can't seem to use struct to identify the jpg

Trying to apply the structs from pset4/resize. Coming up with a quick prototype to make sure i understand structs completely. 1) I keep returning nothing in my output. Can someone tell me what's ...
olafironfoot's user avatar
1 vote
1 answer
37 views

PSET4 LESS BLUR function -Ending Edges problem 2nd version

New version of my previous problem here PSET4 LESS BLUR function -Ending Edges problem I know the problem is with the imitations but can't figure out what is it My code works fine but for the ending ...
Ahmed Elbessfy's user avatar
1 vote
1 answer
739 views

Why does the ball glide along the paddle whenever it touches its sides?

I have no idea why the ball will glide through the paddle when the side of the paddle is hit. It is not the same as normal case when the ball hits the top of the paddle and it bounces back. I have ...
Doufulai's user avatar
1 vote
0 answers
999 views

pset4 how to enhance the colors in the background

How do I enhance the colors in the background. I've added white colors to the image, making it much more visible, but not sure whodunit. I am trying to enhance the sky blue in the image so that I can ...
Dylan Savoury's user avatar
0 votes
1 answer
278 views

Trouble opening pset4 Clue.bmp

I'm having trouble opening the clue.bmp file. Every time i try to open the file to work on whodunit.c it seems to freeze gedit and i have to close the window and reopen gedit. DOes any one know What ...
Joseph Aaron Woodward's user avatar
0 votes
2 answers
294 views

PSET4 RECOVER Can't Open JPEGS, I Have Tried Everything Please HELP!

so this is my second time posting about this pset, my code is below. No images will open, with the current code. However when I do get something to open it is just 1 file and it says invalid or ...
stabilo's user avatar
0 votes
1 answer
126 views

Pset 4: Stuck in a loop again (all green pixels)

So, I've figured out how to change the file headers and all. Works beautifully. The large image is the right size. I couldn't be happier. However, the large bmp image is just filled with neon green ...
Dominikus Dermann's user avatar
0 votes
2 answers
3k views

PSET 4 Recover Help with reading 512 byte blocks.

I'm having some trouble trying to read and loop through the card.raw file. I'm not running into any errors though I can't figure out why when I call fread I continually get 0 as a return value. My ...
ndjustin20's user avatar
0 votes
2 answers
3k views

PSET4 Filter: Blur help

While trying to create an algorithm to come up with the average of the color for all nine pixels (if using 9) I realized I would need a way to see how many surrounding pixels are used in the ...
ayeeitsalpha's user avatar
0 votes
1 answer
315 views

Error in my pset4 resize.c code

I have written this resize.c code it compiles but gives following error when run: runtime error: unsigned integer overflow: 18446744073709551613 * 3 cannot be represented in type 'unsigned long' ...
Ahmed Raza's user avatar
0 votes
1 answer
67 views

Code compiles but files are not read. Recover pset4

Trying to find the problem i could track it to the else statement where ""printf("Could not open file because NULL.\n");"" is located. The files are not read at all or ...
Francisco Azocar's user avatar
5 votes
1 answer
695 views

Is something wrong with getType(object)?

For pset4, in this code(in main, to check collision of ball and anything else): GObject object = detectCollision(window, ball); if (strcmp(getType(object), "GRect") == 0) { ...
Confused Guy's user avatar
3 votes
1 answer
458 views

Bricks are not available to the detectCollision function

My detectCollision function detects collisions between ball and paddle, but not between ball and bricks. Bricks 'exist' in 'window' but they don't exist in main(). I thought detectCollision might ...
Shaun Brophy's user avatar
3 votes
1 answer
970 views

pset4 resize.c negation of 12 cannot be represented in type unsigned long

BITMAPFILEHEADER new_bf; BITMAPINFOHEADER new_bi; new_bf = bf; new_bi = bi; new_bi.biHeight = bi.biHeight*factor; new_bi.biWidth = bi.biWidth*factor; int padding = (4 - (bi.biWidth * sizeof(...
Vincent Tang's user avatar
3 votes
1 answer
639 views

pset4 debugger stopping

In the copy.c program, when my debugger reaches line 37 FILE* outptr = fopen(outfile, "w"); I can step into it twice, but then the debugger immediatley exits with this prompt Compiling /home/ubuntu/...
user10805's user avatar
2 votes
2 answers
323 views

pset4 recover: recovered images seems to still be corrupted

My code compiles and runs without any errors. Images are generated, but the images are incomplete, here's an example of 000.jpg: https://i.stack.imgur.com/gCTju.png. I can't really find what's wrong ...
Birkhoff Lee's user avatar
2 votes
1 answer
2k views

Resize's Padding Issue

My resize for pset4 finally worked and I can resize the small.bmp (that green square) properly. however it doesn't work for all the check50 requirements(except for compiling and running) and i don't ...
Florence Wu's user avatar
2 votes
1 answer
1k views

pset4 recover I'm confused with fread

I'm pretty confused with recover. I've seen in previous posts that it is wrong to use feof , but the problem is that when I use fread the images won't show. However, when I use feof I can see all ...
Belen's user avatar
  • 87
2 votes
2 answers
283 views

Breakout slows down just before finishing the game

Just before finishing a game of Breakout, the game start to move very slow and the paddle behaves weirdly. The game works fine for the first 40 bricks. What causes this? This is my code: GObject ...
julio's user avatar
  • 25
1 vote
1 answer
2k views

Am I using sprintf correctly?

As suggested, I am employing sprintf to write the file names for the recover assignment. I am not sure if I am using the pointer * correctly. The documentation for sprintf shows the first argument to ...
Haim's user avatar
  • 185
1 vote
1 answer
1k views

PSET 4 - resize.c less

This is my code: // Resizes a BMP file pixel by pixel, given a factor n #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper ...
Pexan's user avatar
  • 19
1 vote
2 answers
596 views

Make label with different name's other than label.c

My question is why I cannot simply make a different version of label.c with another file name? Let's say I save it as labelTest1.c; I get this error: jharvard@appliance (~/Dropbox/src5m): make ...
user1538's user avatar
1 vote
1 answer
969 views

pset4 recover works correctly but fails check50

Morning, I have just finished pset4 recover. The program works correctly and I can see all 16 jpgs and they are labeled correctly however check50 is failing:- jharvard@appliance (~/Dropbox/CS50/...
Gordon's user avatar
  • 13
1 vote
1 answer
1k views

PSET4 - Recover - Undeclared Identifier "img"

I keep trying to compile this code and it tells me "img" is an undeclared identifier. If I try to declare it, it tells me I'm shadowing a local variable. I'm not sure what the solution is. I have ...
Rachel's user avatar
  • 13
1 vote
2 answers
110 views

Pset4 recover.c compiles, but can't seem to print Jpgs at all

Am starting a new thread as I'm having trouble understanding what is wrong with the code.. I've added printf statements at the jpgCheck function and did not get a print. I suspect it's the function? ...
olafironfoot's user avatar
1 vote
1 answer
552 views

Pset4, resize, fseek, vertical scaling

I think I've gotten the horizontal resizing to work, however, I just don't get what's wrong with my vertical resizing. I've seen similar questions to mine, and I'm pretty sure my problem (assuming ...
Useful_Investigator's user avatar
1 vote
2 answers
683 views

Can't run Breakout outside of appliance

I have just finished implementing Breakout, and tried running it outside of the appliance in my Debian machine, but i get the following error, even though it's the same directory that's shared between ...
Oussama's user avatar
  • 27
1 vote
2 answers
1k views

pset4 recover: last image not recovered correctly

My program does return all 50 jpegs, check50 says that the last file is not recovered correctly. Unfortunately, I have no idea of why - I check for the end of the file before reading new data into the ...
Laura's user avatar
  • 17
0 votes
1 answer
57 views

Pset4 recover produces only 2 corrupted iamges

I am at Pset4 recover pset. When I run my code, it produces only 2 corrupted images here is my code : #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef uint8_t BYTE;...
Ahmed Elbessfy's user avatar
0 votes
1 answer
401 views

pset4 ball won't move on click?

I'm having some trouble getting the ball to move when the user clicks at the start of the game. I have the code below positioned in main, right after everything is instantiated, and before the while (...
Jane's user avatar
  • 13
0 votes
1 answer
77 views

why does it fail check50 for the last image?

#include <stdlib.h> #include <stdio.h> typedef unsigned char BYTE; int main(int argc, char *argv[]) { if (argc != 2) { return 1; } FILE *infile = fopen(argv[1], &...
Premansh Pareek's user avatar
0 votes
1 answer
23 views

PSET4 LESS BLUR function -Ending Edges problem

My code works fine but for the ending edges not. I mean the right & bottom edges values. Here is my code : void blur(int height, int width, RGBTRIPLE image[height][width]) { // h = 400 w = ...
Ahmed Elbessfy's user avatar
0 votes
1 answer
78 views

Pset4 resize(less) output issue, using third argument of fwrite

In Pset4 resize(less), I try to resize the width of image by using fwrite. gain is integer I use for resize factor. Originally I was doing like this. I put gain to the third argument of fwrite, and ...
Arel Lin's user avatar
0 votes
1 answer
80 views

In recover, image files are not writing bytes correctly. Why?

All 49 images are written but they don't have the accurate data. I can't find where I made the mistake. Here's my code: #include <stdio.h> #include <stdlib.h> #include <stdint.h> // ...
Sakib Arifin's user avatar
0 votes
1 answer
122 views

Issue with padding when horizontally resizing. (pset4, resize (less))

So far, I have only implemented a horizontal resize to my code (I will implement the vertical resize once I have resolved this issue), and, though the code works properly on images such as large.bmp ...
Sam Devo's user avatar
0 votes
1 answer
506 views

PSET4: error: Found "result" when expecting ","

When the updateScoreboard function is called, it throws the above error. The function (all pre-written code) is as follows: void updateScoreboard(GWindow window, GLabel label, int points) { // ...
tmac1's user avatar
  • 3
0 votes
1 answer
173 views

Detecting if we already found a jpg

I'm having trouble figuring out how to print extra 512bytes, if the first jpg is longer than that, like how to loop UNTIL it hits the next 4 header indicators. In this code example I've tried with a ...
Jake's user avatar
  • 34
0 votes
1 answer
50 views

CS50 Pset4 Logic Problem

I am 3 days into PSET 4 Recover. In PSET 4 we are supposed to create a program which inputs a memory card and scans through that memory card for the signatures of lost JPEG files. Once the header of a ...
Ciaran Egan's user avatar
0 votes
1 answer
198 views

Pset4 Recover conceptually struggling

Pset4 Recover is different since it uses files; fopen, fcloser, fprintf, and fread. It adds a whole new dimension to the coding. Its change from just formatting conceptions to making sure all the ...
wardthomas17's user avatar
0 votes
1 answer
279 views

How to Return a GRect From initPaddle()?

Just one quick question, what should I return in the InitPaddle function? I made to put it on screen without returning anything, but in the step to step tips ain the pset`s page says that I have to ...
Joao Turolla's user avatar
0 votes
2 answers
381 views

PSET4 filter (more) - edge

I have wrong output values :( :( edges correctly filters middle pixel expected "210 150 60\n", not "210 32 203\n" :( edges correctly filters pixel on edge expected "213 228 255\n", not "213 ...
Lukkar's user avatar
  • 3
0 votes
4 answers
726 views

How to make ball initially go at random angle?

I don't want to have my ball go at a random velocity when it starts, just a random angle with respect to x. The specs say to use drand48, which I tried, but that makes the ball go really slowly or ...
dottified's user avatar
0 votes
1 answer
71 views

CS50 Recover JPG's not rendering correctly

My code is recovering 50 images, but according to check50 the images are not being recovered correctly. A few of the images are obviously not recovering but I can't figure out why in my code. Several ...
Sean's user avatar
  • 53