Questions tagged [pset3]

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

0
votes
1answer
24 views

pset4 recover - doesn`t recover all files

Struggling with recover at this moment. My code creates just 8 pictures out of 50 - from 2nd to 9th. Other jpegs are also made but i am unable to see them due to "Invalid or Unsupported Image Format". ...
0
votes
1answer
29 views

Need help finding bug in resize

I have been staring at this code for hours now and can't find what is wrong with it. It makes a new bmp image that is "n" times larger, but there is something wrong with the reading frame because the ...
0
votes
1answer
18 views

pset3 recover, only get 49 jpgs and all are wrong by check50, but look correctly

I recently started with CS50 and I struggle a bit with pset3's recover. While the jpgs look correct to me, my code only recovers 49 jpgs total, not the 50 which are expected. Check50 fails on the ...
0
votes
1answer
15 views

pset3 Recover - problem with final image

Hi I'm working on recover in pset3 and seems there is some problem when my code ends, can anyone point out the direction I should look into? Check50 returns the following error while all others are ...
0
votes
1answer
9 views

Move function do not working

I cant understend why, but my move function does not work properly. It looks correct to y mind. But no Can you please chck what's wrong? bool move(int tile) { if(tile > d*d-1 || tile <= 0) ...
0
votes
1answer
27 views

PSET3: Resize (more comfortable) - What am I doing wrong?

This code outputs a seemingly random assortment of colors after the initial scanline, which is correct. If I comment out the for loop that fwrites the scanline "n"(the multiplier) times for every row, ...
0
votes
2answers
35 views

Pset3 recover __ How can I read and store data from card.raw to an array, and print this data-array byte by byte?

(This is the 1st time I use this site) I've tried many different ways, and all failed. Mostly 0s are being printed. Any idea how to approach this? I've spent the entire week on this already. Actually,...
0
votes
1answer
25 views

PSET3 Resize (Less) - works in debug50 but segmentation error when executing

I'm working on resize (less comfortable) in pset3 and it returns segmentation error when I execute the code. However, when I try to work out which line actually went wrong using debug50 and go through ...
0
votes
1answer
33 views

Is scan line not moving to the next line? I'm badly stuck. Please advice

I am getting only one green line, then a brown line and rest (about 90%) of the space filled with white and grey squares. I think, I am facing problem in moving the cursor to the next line. I tried to ...
0
votes
1answer
63 views

Where am I going wrong with this resize?

My output is a grey square with a white rectangle at the top and bottom. What is it fwriting? // iterate over infile's scanlines (for each row) for (int i = 0; i < bi.biHeight; i++) { //...
0
votes
1answer
75 views

Resize ( more comfortable )

int main int argc, char *argv[]) { // ensure proper usage if (argc != 4) { fprintf(stderr, "Usage: copy infile outfile\n"); return 1; } float f = atof(argv[1]); if(f<= 0.0 && f>=...
0
votes
0answers
37 views

PSET3 Resize -resizes correctly Byte… doesn't match

I don't understand what I did wrong... Here's my code : // Copies a BMP file #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { int n = ...
0
votes
1answer
21 views

Why would this expression always return true?

Here is the function I'm using to test if the first four bytes of the buffer match the header file for a .jpg image. When I compile the program (in its very early stages) it reports that the function ...
0
votes
1answer
40 views

Recovered image does not match pset3

I can't figure out what is wrong with my code. I recovered images from 000.jpg to 050.jpg. This is my code #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef ...
0
votes
1answer
21 views

PSet3 helpers.c fails one of the checks

I'm working on the PSet3 Find problem. Here's my code for the sort and search functions: bool search(int value, int values[], int n) { if (value < 0) return false; else { ...
0
votes
1answer
34 views

recover.c producing random image 🙁

recover.c is always producing this image: Here is my code: #include <stdio.h> #include <stdint.h> typedef enum {false, true} bool; // Bool int main(int argc, char *argv[]) { if (...
0
votes
0answers
30 views

recover.c spits out images that are partially recognizable

recover.c compiles and runs normally, but it produces 21 images that have chunks of different images mixed in. Here are the images: 000.jpg: 001.jpg: 002.jpg: 003.jpg: 004.jpg: Because I'm too ...
0
votes
0answers
13 views

recover.c spitting out a random image

My recover.c compiles and runs (unlike previous attempts), but the program spits out a random image, as shown here: Because I don't have enough space, my code can be found here See Update
0
votes
1answer
28 views

pset3 recover is fopen changing the first value in my buffer?

My code for pset3 works and recovers all the images as it is supposed to however I realised that when I call fopen the first value in my buffer array becomes 0 I fixed this by changing the value back ...
0
votes
1answer
40 views

PSET3 - resize help

I have been trying to figure this out on my own for a long time. No success. Then I tried to look for online help but could not find specifically what I wanted. It's true that I found alternative ways ...
0
votes
1answer
26 views

CS50 recover - images are some kind of blank

//My program creates images of different sizes but without content (just black and white pixels). Someone can help me? #include <cs50.h> #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
76 views

Resize(less) How to store triple into an array?

I have been struggling with resize (less). I can't seem to make sense of how to put the value of triple that is being read into an array (rewrite method) Any help will be appreciated // iterate over ...
0
votes
1answer
23 views

recover.c:43:34: error: use of undeclared identifier 'out' fwrite(temp, 1, 512, out);: WHAT?

When I compile my program, clang is probably not working. I get this when I compile: ~/pset3/recover/ $ make recover clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -...
1
vote
1answer
66 views

pset3 recover not sure how the code works

I'm taking baby steps towards writing the code for recover. So far I have written this: int count = 0; int blocks = 0; // Loops through the whole card. while (feof(card_in) == 0) { // declares ...
0
votes
2answers
84 views

Pset3 Resize Array not storing data properly

I'm not sure where the issue is here, but from the looks of debug I only store anything in my horizontal array (line) once despite seeing the debugger hitting that section of code properly. I assume I ...
0
votes
1answer
40 views

pset 3resize (less) how to store RGBTRIPLES in array

I am trying to store the RGB triples in the source file in an array, but I don't understand which variable type they are supposed to be. I have tried char, int, BYTE, unsigned long. The latter ...
0
votes
1answer
93 views

PSet3 WhoDunit open ended question materials

I'm currently on Pset3 WhoDunit. Part of the task is to answer open-ended questions. What I don't quite get is the connection of these questions to the Lecture or Shorts - some of the questions are ...
0
votes
1answer
57 views

Why isn't resize(more) printing properly?

I am back again with another question about resize more. I feel like I am pretty close, but for some reason it is not resizing vertically properly when the factor is larger than 0 (I haven't dabbled ...
1
vote
1answer
64 views

Pset 3 - recover. code only returns 30 images, all of which are glitchy

Some of the images returned are filled halfway, some not so much, all being glitchy colors. Not really sure what I'm doing wrong #include <stdio.h> #include <stdlib.h> #include <string....
0
votes
1answer
73 views

pset3 resize(less) working correctly, but check50 show a bunch of "image has more bytes than expected

I'm not sure where I went wrong that is causing it to add too many bytes. When I test the program, it seems to resize everything correctly. Code: #include <stdio.h> #include <stdlib.h> ...
0
votes
1answer
48 views

Random Black Pixels on Resize More

I am currently working on Pset3 Resize More. This is something I have never really done before, and I am really not sure if I am missing something major or not. Right now, I know that I can't shrink ...
0
votes
1answer
26 views

pset3/resize same expexted sizes for different scales

While resolving resize(less) problem I've encountered check50 expects the same sizes of files with different scales. How could that be? :( doesn't resize small.bmp when n is 1 Header field biSize ...
1
vote
1answer
92 views

Pset3 - Resize (less confortable)

I am getting an error at IDE "Invalid or unsupported file format" for an input "n" equal or greater than: 68 for small.bmp 36 for smiley.bmp 27 for large.bmp I also tried to peek with staff's ...
0
votes
1answer
145 views

Pset 3 Resize (Less) : Still stuck, likely problem with changing bitmap size

Been stuck on Pset3 Resize (Less) for days... I think i got my headers right, but i am unable to resize the image size properly. When i try to resize small.bmp, it goes from this: to this: Will ...
0
votes
1answer
54 views

pset3 resize (less) compiles but doesn't write into new file for factor != 1

I've been stuck with the pset3 for a long time now and can't figure out why my code isn't working; it compiles fine but doesn't produce an image except for the factor 1. Could someone point me in the ...
0
votes
2answers
103 views

Pset 3 (Recover): Why are images still glitchy?

I've been having trouble with pset3's Recover exercise. My code successfully compiles and creates 50 jpegs, numbered 000 to 049. However, all images are terribly glitchy. Examples: I've scoured the ...
0
votes
0answers
47 views

pset3 resizing - when scale between (0-1)

I am a bit stuck with the resize exercise, especially when the scale factor is between 0 - 1. I have written the following code, which conceptually felt correct but I am not getting the chart as ...
0
votes
2answers
38 views

pset3 recover output not valid ASCII text

I'm recovering all 50 JPEG images, but still failing check50 with the message: "output not valid ASCII text." Not sure if this might have something to do with it, but for some reason, my buffer[0] ...
0
votes
1answer
160 views

Resize (more comfortable) - Code does not pass last 3 check50 test (shrinking by 0.5)

For the 2019 version of Resize (more comfortable), my code is able to pass all but the final three tests: :( resizes 6x6-pixel BMP to 3x3 correctly when f is 0.5 expected exit code 0, not 1 :( ...
0
votes
1answer
51 views

pset3/resize - segmentation fault

I'm getting a segmentation fault and tbh have no idea why. I run valgrind and it all seems good, no memory leak. If I run debug50 the code just switches off halfway through execution on line 43 giving ...
1
vote
1answer
166 views

Problem Set 3 (Resize) Help

I have been working for a while now, and I have a few questions regarding the Resize problem set. My code makes sense to me intuitively, but I am sure I went wrong somewhere, as my output is clearly ...
0
votes
1answer
24 views

Need help with Frequency in pset3. Been stuck for a while

So to start off, I'm going to include my code at the end of the question. Basically, I've built this function a few times now and I'm kind of at my wits end here. My code uses a for loop to iterate ...
0
votes
1answer
84 views

resize pset3, getting stuck between the lines

Seems to be working on the first line of resizing, but then something is missing and not copying the correct RGB Triples - the color scheme gets completely off... Have tried playing with all the ...
1
vote
2answers
403 views

Stuck on pset3, Whodunit

In Whodunit, you are asked to go into CS50 Lab and answer questions on how a file called copy.c works. They give you two links to BITMAPINFOHEADER and BITMAPFILEHEADER. Then, it says you should open a ...
2
votes
0answers
182 views

Whodunit No Files

I'm about to start pset3, but the terminal keeps disconnecting, and so I refresh the page. When it opens again, the CS50 Lab no longer has any of the files, and I can't see what the copy.c files does ...
0
votes
2answers
25 views

Pset3, Issue with duration in helpers. Can't compile, strange error message

Back again, this time trying to figure out pset3. I think everone is familiar with the pset, but for anyone who isn't, I'm trying to convert a fraction (1/8, 1/4, 1/2, etc) to a number of eighths. ...
0
votes
1answer
36 views

CS50 Pset 3 Music errors - please help! :(

I really don't know what I am doing wrong. I think I've mad a mistake in frequency. Check50 says: :( note C3 has frequency 131 expected "131", not "220" :( note Bb5 has frequency 932 ...
0
votes
1answer
35 views

Pset3 Frequency Algorithm

I was working through the Pset3 Algorithm, and have all ready written my code, and when check50 runs, I did pretty well. However, the check states that :( produces all correct notes for octaves 3-5 ...
0
votes
1answer
40 views

Please help!! I am facing problem in pset3

I am facing problem in understanding the meaning of------ helpers.c:90:3: error: expected identifier or '(' Please guide me in correcting this error. Thanks a lot in advance.
0
votes
1answer
55 views

pset 3 Duration non object type error

Getting error message at compile. helpers.c:17:18: error: non-object type 'int (string)' (aka 'int (char *)') is not assignable duration = numerator; My code is as follows: int duration(...