Questions tagged [pset3]

The problem set for Week 3 asks students to write code for a classic puzzle game in the C programming language.

Filter by
Sorted by
Tagged with
0
votes
1answer
1k views

Error: control may reach end of non-void function [duplicate]

I am currently working on pset3/search and when I try to compile the codes it keeps telling me that ^ error. I know that it is because I must not be returning a boolean value as needed, but I do not ...
2
votes
2answers
354 views

why can't I compile the program that I wrote to test helpers.c?

I've made a program to test my sort function. The only problem is that when I try to compile it gives me the "undefined reference to 'sort'" error as seen in the below: For context, I have taken the ...
0
votes
1answer
266 views

Why is my do..while loop executing only once?

I have tried to use a do-while outer loop with a for inner loop to implement bubble sort, but it appears to be executing once through the for loop and then not satisfying the while condition. The ...
0
votes
1answer
1k views

How to fix the “expected identifier or '('” error?

I've been stuck at this for a long time. How can I fix this error?
0
votes
1answer
167 views

Breakout Bricks coding caused segmentation-fault error! HELP!

After coding my Bricks for BREAKOUT, I get Segmentation error and my Paddle, Ball, and Scoreboard no longer appear! The bricks look great, but everything else disappeared and I get the fault error. ...
0
votes
1answer
201 views

Sort is not working on Pset3

After many hours can't figure out why the sorting and searching is not working... When running tests it I always get "Didn't find needle in haystack" whether the value is in or not in the array... ...
0
votes
1answer
398 views

Pset 3 error - Binary search

I'm having some difficulty implementing binary search. I wrote linear search with no problems but when I compile my code for binary search, I get an error. I decided to take the iterative approach ...
0
votes
3answers
342 views

I can't check sort in Helpers.c

After reading the other questions, I still don't get how to check it. I tried to use gdb on ./find, but while I ran it, I could only see what was expected. Then, while typing n, it said "in fileops.c"...
0
votes
1answer
157 views

Can we attempt problem set 3 after week 3's lectures

Or do we need to get through week 4's lectures as well?
0
votes
2answers
89 views

Bricks for Breakout won't fill top of window

My bricks don't fully print. I get: XXXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX I can't figure out why I am missing the first brick in each of rows 2-5 ...
0
votes
1answer
98 views

Breakout code giving negative lives

Everything in my Breakout code works except for the Lives count. Instead of decrementing from 3 to 0, it continues to decrement into negative values. Is it the "lives--;" line that is wrong, or is it ...
0
votes
1answer
58 views

Confusion about if/else statements

Why wouldn't you put a corresponding else statement within the for loop? The return false at the bottom corresponds to the for loop, but nothing corresponds to the if statement (it doesn't work when I ...
0
votes
1answer
319 views

Pset3 Find Check50 is Inconsistent

When I run check50 on the find program for Pset 3 I get an inconsistent error about output from CLang. Sometimes it works and other times it produces an error on one of the tests. The error can be ...
0
votes
1answer
163 views

pset3 helpers.c not working

this is my code for the top part { for (int i = 0; i < n; i++) { if (values[i] == value) { return true; } else { ...
0
votes
1answer
139 views

Pset3 breakout issue with the while live > 0 && bricks > 0

I am trying to create the while lives > 0 && bricks > 0 loop but either the ball doesn't bounce off the right wall or the paddle doesn't follow the mouse. My code is below. Please help been ...
0
votes
1answer
723 views

In Breakout the ball latches itself to paddle and bricks occasionally

While moving the ball it sometimes sticks itself to the y co-ordinate and moves around the same co-ordinate for both bricks as well as paddle. Please help. Been stuck on this for a while and can't ...
0
votes
1answer
227 views

pset 3 breakout - collisions not working

I'm having trouble getting collisions to work in breakout. I wrote my own code, which despite a lot of fixes didn't work, so I attempted to just copy-paste the bounce.c code in an effort to figure out ...
0
votes
1answer
89 views

Breakout - wall collisions work…sometimes

I'm trying to get the ball to collide with all of the walls of the window. My current code works for the first 3 seconds of gameplay but then the ball will jiggle through a wall. I'll show you the ...
0
votes
1answer
205 views

(pset3) breakout initBrick issue

I'm currently trying to instantiate 1 row of bricks before moving on to 5. Before implementing the for loop I made sure I could instantiate 1 brick on the screen, exactly where i want it. No problem ...
1
vote
1answer
466 views

Strange interactions between paddle and ball in Breakout

First of all, here is my code for Breakout (pset3): // // breakout.c // // Computer Science 50 // Problem Set 3 // // standard libraries #define _XOPEN_SOURCE #include <stdio.h> #include <...
0
votes
1answer
131 views

pset3 find.c - error whenever code is compiled

The error is as follows: Even looked at the stddef.h file but unable to figure out anything. The code is as follows:
2
votes
1answer
199 views

Segmentation fault testing for detectCollision returning NULL

I am trying to detect collisions between the ball and paddle or bricks. The difficulty for me is trying to determine if detectCollision is returning NULL. An excerpt from my code is shown below. This ...
0
votes
2answers
141 views

Why generate in pset3/find/Makefile doesn't have “-lcs50” to link cs50.o?

In pset3/find/Makefile, if somebody has noticed find has "-lcs50" flag to link the libcs50.a file but generate doesn't though generate.c includes cs50.h. Why?
0
votes
0answers
45 views

pset3 gwindow header include error in window.c file

pset 3 gwindow header file error.my appliance vesion is 19-2 and when i am include gwindow.h it show an error for which i have attached screenshot below. pls help me ASAP.
1
vote
1answer
117 views

Segmentation fault when using move() in Breakout

could I get a little help with pset3 Breakout please? I want to get the ball to move and bounce - I modified bounce.c to do this beautifully but when I put the code into breakout.c, it compiles ok ...
0
votes
1answer
394 views

breakout - ball takes out too many bricks

I have breakout mostly working, but I can't figure one issue out. Sometimes, my ball will break through multiple bricks. Instead of hitting one and bouncing back towards the bottom, it rips through a ...
0
votes
0answers
55 views

Pset3 : Ball doesn't begin motion from center of window

I initially instantiated the ball in the center of the window using the initBall function. However after I implemented the code to move the ball randomly across the window, it doesn't begin its motion ...
1
vote
2answers
3k views

Pset3 Binary Search problems

I have tested the code presented in the picture and find this function always returns false no matter what number you search.There must be a problem in it but I can not see it!! Can anyone help me ? ...
0
votes
2answers
9k views

pset 3 GDB: “no executable file specified”

I've been working my way through CS50 and I'm having a problem I hope someone can help me with. I can't get GDB to function at all, and I think it might be a problem with startup - when I type "gdb" ...
0
votes
1answer
168 views

breakout initBricks Why do I get 10 rows and 5 columns?

So I have been trying to initiate the bricks for breakout in pset3. But the outcome of my nested loop is this : I don't understand why I get 10 rows and 5 columns of bricks, rather than 5 rows and ...
0
votes
1answer
58 views

PSET3 search - find program doesn't accept input

could someone please help to figure this one out? find program doesn't seem to be taking input, whether piping input from generate, or from text file either... thanks for a look in here ! ok, ...
0
votes
0answers
55 views

Linker error with breakout.c

I have attached the linker error and a listing of the files in the directory that contains breakout.c. I think I have the right setup, but it won't compile. the clang command is clang -ggdb3 -O0 -...
0
votes
1answer
70 views

setActionCommand pset3

Per SPL, setActionCommand means: "Sets the action command to the indicated string. If the string is not empty, activating the interactor generates a GActionEvent. Usage: setActionCommand(interactor, ...
1
vote
1answer
585 views

argc value count confusion

I'm having some confusion on Pset3. In the program "generate.c" there is an "if" condition for validating the argument counts. Here is the portion I'm having confusion : if (argc != 2 && argc ...
0
votes
1answer
73 views

swap function in lecture 5 and bubble sort

In lecture 5, David has explained that to actually have swap working, we actually need to point to the address of the string/char/int. However, when I look at my bubble sort code for helpers.c, I ...
0
votes
1answer
44 views

Unknown gWindow error pset3

I was doing the breakout walkthrough for pset3. I looked at the other questions which talked about a compilation error using gwindow. I tried the solutions there but it didn't work, and this error ...
0
votes
1answer
123 views

Swap initialised in Bubble sort

I watched the Section video in week 3 which discussed Bubble sort. I also watched the lectures and the shorts on it. I understand how it works, except for one bit. I'm confused on the below image from ...
1
vote
1answer
86 views

Compiling pset3 breakout on my native ubuntu

I want to run the breakout game on my native ubuntu. I tried installing the SPL files and making certain changes to the Makefile. But it's still not compiling. Has anyone else got it to work?
1
vote
1answer
152 views

Why function initBricks is void type if initBall is GOval?

i was wondering why those functions are different types ? Especially why initBricks is void? // prototypes void initBricks(GWindow window); GOval initBall(GWindow window); GRect initPaddle(GWindow ...
0
votes
0answers
91 views

Why paddle is not visible at bottom middle of window?

I have instantiated the function initPaddle(). The function returns a paddle and I can see it in the window at various location coordinates that I provide. But, when I provide location coordinates ...
1
vote
1answer
152 views

Breakout (with no changes) won't compile

I always get the following messsage when I try to compile breakout in PSET3. jharvard@appliance (~/Dropbox/CS50/pset3/pset3/breakout): make breakout clang -ggdb3 -O0 -std=c99 -Wall -Werror -Wno-...
0
votes
1answer
244 views

How to initiate bricks in pset3 breakout game?

I can't copy the code from VMWare to Windows, so I took a screenshot: http://i.imgur.com/lKM8EgE.jpg What am I doing wrong? I think my logic is correct and my code should work. I get this output: ...
1
vote
1answer
113 views

Why does setLabel() freeze the program randomly?

I have a decent implementation of the Breakout program that normally runs perfectly all the way through. I have noticed, however, that occasionally the program will freeze. After a joint effort of ...
0
votes
1answer
259 views

pset3 Ball not detecting bricks

I have used detectCollision to make the ball bounce off the paddle. I have tried to use it to make the ball bounce of the bricks but it does not. Actually, it does not compile. This is the piece of ...
0
votes
1answer
67 views

How to execute the given instructions properly to get unzipped files of src4m.zip in pset3?

While trying to download the unzipped files as per instructions of "Braking out", I encountered a problem. The first time I executed the following instructions in the terminal, it did work and I got ...
0
votes
1answer
893 views

Where am I going wrong in opening staff's solutions in various psets?

Currently I am in Week4 - pset3 and tried to open from terminal the staff's solution as follows: (/Dropbox/pset3/breakout): cs50/pset3/breakout I get the following: -bash: cs50/pset3/breakout: no such ...
0
votes
1answer
261 views

ball colliding with scoreboard

Just as the title says. When I remove the function to make the scoreboard the ball moves past the middle of the screen. I've tried using draw() and sendToBack() on the label thinking the ball would ...
0
votes
1answer
80 views

Infinite loop if “needle” not found in array

I have a slight problem where if I search the array and the number is there everything works, the needle is found. However, if the needle is not found I go into an infinite loop which returns the ...
0
votes
1answer
148 views

Pset3: First row of bricks are not removed (rest all are removed)

The first row of the bricks are not removed. The ball goes above the first row of bricks and bounces the top wall comes down. But still the top row bricks don't disapper. Is there something amiss with ...
0
votes
1answer
494 views

Pset3, detect collision, paddle not ‘colliding'

I used the code given in the set GObject object = detectCollision(window, ball); if(object !=NULL) { if(object== paddle) { y_velocity=-y_velocity } } else if (strcmp(getType(object), "...

1
20 21
22
23 24
26