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
3answers
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 ...
1
vote
1answer
1k 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 ...
0
votes
2answers
418 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 ...
2
votes
1answer
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 ...
4
votes
4answers
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 ...
1
vote
4answers
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 ...
0
votes
1answer
310 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' ...
1
vote
1answer
720 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 ...
2
votes
2answers
697 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 [-...
1
vote
0answers
998 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 ...
1
vote
1answer
206 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 ...
0
votes
1answer
17 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 ...
0
votes
2answers
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 ...
0
votes
1answer
277 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 ...
0
votes
1answer
120 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 ...
0
votes
2answers
239 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 ...
0
votes
2answers
2k 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 ...
2
votes
2answers
273 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 ...
1
vote
2answers
674 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 ...
0
votes
1answer
121 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 ...
0
votes
1answer
240 views

Pset4 odd behavior

I can't really figure out while my code end up making a weird version for the resize pset. It compiles and run but the image is not quite what it's suppose to be. Thanks for your support! [EDIT: ...
5
votes
1answer
689 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) { ...
3
votes
1answer
622 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/...
3
votes
1answer
449 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 ...
3
votes
1answer
950 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(...
2
votes
2answers
293 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.imgur.com/Ovs2Xv8.png. I can't really find what's wrong in my ...
2
votes
1answer
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 ...
2
votes
1answer
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 ...
1
vote
1answer
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 ...
1
vote
2answers
105 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? ...
1
vote
2answers
591 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 ...
1
vote
1answer
939 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/...
1
vote
2answers
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 ...
1
vote
1answer
542 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 ...
1
vote
1answer
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 ...
0
votes
1answer
504 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) { // ...
0
votes
1answer
77 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 ...
0
votes
1answer
144 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 ...
0
votes
1answer
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 (...
0
votes
2answers
166 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 ...
0
votes
1answer
50 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 ...
0
votes
1answer
149 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 ...
0
votes
1answer
278 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 ...
0
votes
1answer
14 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 = ...
0
votes
1answer
31 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;...
0
votes
1answer
52 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], &...
0
votes
1answer
46 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 ...
0
votes
4answers
698 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 ...
0
votes
1answer
46 views

Help with unloading my dic

I have been trying speller for far too long now and need help with unloading the dictionary. This is the code I have now // Unloads dictionary from memory, returning true if successful else false bool ...
0
votes
1answer
62 views

pset4(recover-less): Segmentation Fault

#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> int main(int argc, char *argv[]) { // ensure proper usage if (argc != 2) { ...