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
9
votes
3answers
896 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
409 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
308 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
711 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
602 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
1answer
194 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 ...
1
vote
0answers
995 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 ...
0
votes
1answer
119 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
1answer
272 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
2answers
1k 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
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 ...
0
votes
1answer
149 views

pset4 Unsupported File Format

Been messing with this code for days, but when I was debugging it the program went from printing a distorted image to simply saying Unsupported File Format in the command line. Not sure where I'm ...
0
votes
2answers
181 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 ...
2
votes
2answers
272 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
687 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
448 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
537 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
939 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
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 ...
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
2answers
241 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 ...
1
vote
1answer
539 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
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
894 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
98 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
1answer
998 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 ...
1
vote
1answer
873 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
589 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 ...
0
votes
1answer
76 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
400 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
1answer
45 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
116 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
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
2answers
250 views

PSET4 Recover Problem to repair .jpg's signature in hexadecimal

I'm not sure if I use correctly the hexadecimal notation to verify if there is a .jpeg signature in the beginning of my BLOCK of 512 bytes. My program compile well but no photograph is revealed. May ...
0
votes
1answer
42 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
445 views

Compilation error when using #include “gwindow”

When compiling a game program I keep getting an "unable to find" error directed to the Stanford Portable Library (#include gwindow). I have tried unzipping all files in pset4, searched Google and ...
0
votes
1answer
660 views

I don't understand what is going on my resize? Actually probably resize too

I have tried many days on resize. I take a break 1-2 week because of external reasons. I Watched zamyla many times and read many articles on stackexchange. but I could not understand. Here is my code. ...
0
votes
3answers
358 views

pset4 resize.c check50 gives error even though resizing is done correctly

I used the peek command to check my headers using the command ~cs50/pset4/peek student.bmp staff.bmp and everything is alright and perfectly matches with the staff's implementation as follows : ~/...
0
votes
1answer
652 views

getting runtime error: unsigned integer overflow

#include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char* argv[]) { // ensure proper usage if (argc != 4) { printf("Usage: ./copy n infile ...
0
votes
1answer
511 views

Trouble Compiling, Comparison between Pointer and Integer?

I'm having trouble compiling my recover.c code as the compiler is telling me that I'm trying to compare an integer to a pointer? This is referring to the check to see if the first characters in the ...
0
votes
1answer
436 views

pset4 resize what is wrong?2

Now it's a little bit better since: :) resize.c and bmp.h exist :) resize.c compiles :( doesn't resize 1x1-pixel BMP when n is 1 :( resizes 1x1-pixel BMP to 2x2 correctly when n is 2 :( resizes ...
0
votes
1answer
769 views

CS50 Pset4 Recover Updated

All 50 valid images are created, but the program did not pass Check50. This is my updated code: /** * recover.c * * Computer Science 50 * Problem Set 4 * * Recovers JPEGs from a forensic image....