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
59 views

PSET3 - Resize (Less) : Random colours being printed?

Going through the walkthrough of 'Resize (less)' and currently trying to resize horizontally. When running resize, only a few pixels have the correct colour and others have completely random colours. ...
0
votes
2answers
34 views

Intuition for what is statically allocated memory vs dynamically allocated memory

So I'm just finishing Lecture 3, and even after research, I can't get a visceral handle on the difference between the two. Yes, I know that one is in stored in the heap, and the other in the stack, ...
0
votes
1answer
102 views

What's wrong with this recover code?

I wrote some code for recover that seems to me to be recovering the image correctly (I can see pictures of people for all 50 images), but for some reason, check50 says that 049.jpg does not match the ...
0
votes
1answer
63 views

I can't figure out the problem in my resize (more) code

I was actually able to solve resize (more), but I'm not able to figure out what's wrong with one of my previous codes (the one I was stuck for longest on) This is my old code: #include <stdio.h&...
0
votes
1answer
37 views

pset3 Resize: Header values not copying into outfile

My output.bmp file yields "Invalid or Unsupported Image Format", and using ~cs50/2019/x/pset3/peek output.bmp yields "Could not recognize output.bmp". Using check50 also gives the error "Header field ...
0
votes
1answer
54 views

jpg's are not proper, mix of multiple images. Can anyone tell me whats wrong?“RECOVER”

here is my code while (fread(buffer, 512, 1, inptr) == 1) { if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && (buffer[3] & 0xf0) == 0xe0) ...
0
votes
1answer
46 views

resize : pset3 not all colors are appering after resizing

so im trying to resize an image of green square that has a smaller white square inside it and when i do the resizing the green square resize but the white one disappears i'dont know where the problem ...
0
votes
1answer
52 views

PSET3 Recover - Creating only textfiles for .JPG not images

My version of Recover for pset3 is creating 50 .jpg files but only as textfiles not images and I can't work out why. I've looked through this forum and saw one similar question but the issue ...
0
votes
1answer
71 views

pset3 Resize - Invalid or unsupported Image Format

So i think i finished resizing horizontally but when i try to open the output image to check i get an error saying "Invalid or unsupported Image Format", I read other similar questions here and i ...
0
votes
1answer
62 views

PSET3 Recover: My code works when I make the buffer an array, but not when I use malloc

My code works perfectly when I make the buffer I use in fread and fwrite an array of unsigned chars, but when I use malloc to allocate memory space I get segmentation faults (this is the opposite of ...
0
votes
1answer
75 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
48 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
64 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 ...
1
vote
1answer
59 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
14 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
63 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
87 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
49 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
53 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
88 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
2answers
864 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
103 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
29 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
89 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
27 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
53 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
39 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
1answer
51 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
201 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
46 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
187 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
83 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
192 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
119 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
76 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
163 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
72 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
87 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
86 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
60 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
27 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
126 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
373 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
69 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
246 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
2answers
87 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
360 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
97 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
308 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
35 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 ...

1
3 4
5
6 7
25