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
0
votes
1answer
8 views

pset4 / recover / invalid or unsupported image format

I've been working on RECOVER from PSET4. I'm able to compile and it creates all 50 images. When I try to open any of the images I get an error saying "invalid or unsupported image format". I'...
0
votes
1answer
11 views

pset4 / recover Segmentation Fault

I have been trying to solve RECOVER from PSET4 and I keep getting a segmentation fault. Any ideas on why this happens? Thank you so much for any help. #include <stdio.h> #include <stdlib.h>...
0
votes
1answer
15 views

PSET 4 BLUR and 2 of REFLECT

All of reflect works except reflected a 1 x 2 and a 4 x 4 (3x3 works fine) None of blur works except for when a point is in the corner, which makes little sense. I've sluthed around other answers and ...
0
votes
0answers
7 views

Why does the code output incorrect amounts?

The code is here: https://pastebin.com/gKnVmPFf I've checked that it's not because of neighboring cells, because I am translating them onto a different array. I can't seem to figure out want is wrong. ...
0
votes
1answer
14 views

PSET4 recover: program compiles but doesn't recover any image

So, I'm using quarantine to learn C. I'm currently stuck at the Recover problem. My code compiles, runs but the result is not what I would've expected. I've explained this code to myself a thousand ...
0
votes
1answer
18 views

pset4 - My recover programme compiles but doesn't generate JPEGs as expected

After 12hrs of banging my head against this, and having trawled Stack Exchange, I've decided that it's time to ask for help! Really not sure where I'm going wrong, but suspect it's related to the ...
0
votes
1answer
10 views

pset4 recover only recovers 25 correct images

This is my code for recover. When I run the program, it gives me 25 successfully recovered photos. I don't know why it is only giving me half the required photos. I believe it might have something to ...
0
votes
0answers
10 views

CS50 PSET4. Edges detection algorithm does not filter correctly 3x3 image and 4x4 image

I am working on Problem Set 4 of CS50 and I have some issue with Edges detection algorithm (description of the PSET4 can be found here: https://cs50.harvard.edu/x/2020/psets/4/filter/more/). In ...
1
vote
1answer
7 views

pset4 - Green and Blue off in filter (less)

My code is here. void sepia(int height, int width, RGBTRIPLE image[height][width]) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { ...
0
votes
1answer
33 views

pset4 recover fwrite function

I'm not sure where I went wrong with my code. Am I using fread and fwrite correctly? Thank you in advance!! //opens the file FILE *f = fopen(argv[1], "r"); //if the file contains nothing, ...
0
votes
2answers
41 views

PSET 4 Problem Set Recover

I've been working on Recover a few days now and managed to actually create a program that retrieves the images. The only problem is that they are not retrieved correctly and don't match what they are ...
0
votes
1answer
31 views

PSET4, RECOVER: Segmentation Fault

I have been trying to solve RECOVER from PSET4 and I keep getting a segmentation fault. Any ideas on why this happens? #include <stdio.h> #include <stdlib.h> #include <stdint.h> ...
0
votes
1answer
38 views

For PSET4 recovery, i can compile and now get 49 pictures, check50 error: “recovers middle images correctly recovered image does not match”

I think my "while" condition to read till the end of the file seems correct unlike most of other answers so i'm not sure what is wrong #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
16 views

recover compiles but has segmentation fault when running it with ./recover card.raw, could anyone take a look

#include <stdio.h> #include <stdlib.h> #include <cs50.h> int main(int argc, char *argv[]) { //this counter to keep track of how many jpegs found so far int counter = 0; //allocate a ...
0
votes
1answer
26 views

Pset4 Recover. I think that I did well but it doesn't work

I was struggling with this code for three days. someone could help me? What should i fix? Please, if you are so kind, give me a tip, not the solution! I wrote a lots of comments to you can understand ...
1
vote
3answers
27 views

pset4 filter grey scale error

when I try to test the code I get an infinite loop of errors: UndefinedBehaviorSanitizer:DEADLYSIGNAL what am i missing ??? void grayscale(int height, int width, RGBTRIPLE image[height][width]) { for (...
0
votes
1answer
24 views

PSET4 Filter (more) Edge

I got some weird issue with my code! It compiles without any problems. All other filters work perfectly, and check50 shows no problems (no problem in edge according to check50). But, when i try edge ...
0
votes
2answers
45 views

Issues with PSET4 recover (recover.c), can't create jpg's (segmentation fault)

Can't seem to find what is happening with my code, please help! I've been stuck in this problem for way too long. The jpg's are not created when I run the code. #include <stdio.h> #include <...
1
vote
2answers
36 views

PSET 4 Reflect help

I am not sure why I am having issues with my code. I know I can store the rgb values for the left pixels in 3 temporary variables then assign the right values to the left and the temp values to the ...
0
votes
1answer
12 views

Is there an operator for raising in a power in C?

In PSET4 Edges Filter problem you are supposed to calculate Gx ^ 2. But the operator ^ in C does not seem to mean raising in a power. For Gx = -9 it returns Gx ^ 2 = -11 and so on. Turned out ^ is XOR ...
0
votes
1answer
25 views

Cannot understand why valgrind is giving error although check50 runs properly

In this problem, (filter), I'm receiving all green from check50. But when I ran valgrind for blurring I got the following error: ==4412== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al....
0
votes
0answers
22 views

Segfault error, please help

I really need help, I'm getting a segfault error. Please look through my code and help me, please. #include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(int argc, char ...
0
votes
1answer
32 views

blur pset4 help please, my code compiles but it does not pass any of the check50 at all

Please help with what i did wrong, i cannot seem to find where my logic was wrong and been staring at it for weeks. I've tried to change my approach a few times but does not seem closer at all and ...
0
votes
0answers
10 views

The image updates, yet incorrectly

Here is the link to the full code: https://pastebin.com/kFgWhfTR . The image is calculating incorrectly. I have no idea why. I know that it is not caused by one pixel updating the others.
0
votes
0answers
17 views

PSET4:Blur filter doesn't function

I have this code: // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE tempImage[height][width]; int sumR = 0; int sumG = 0; int sumB = 0; ...
0
votes
2answers
76 views

pset4 recover works correctly but fails check50. (not a duplicate because i want to figure out why MY code does not work)

this is my code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { // Check usage if (argc != 2) { return 1; } ...
0
votes
2answers
32 views

Incompatible pointer types passing BYTE to FILE

#include <stdio.h> #include <stdlib.h> #include <stdint.h> //Define BYTE typedef uint8_t BYTE; int main(int argc, char *argv[]) {//Check if command line is correct// if (argc != ...
0
votes
1answer
39 views

pset4 filters: thinking behind blur

Need some help with blur. I think i'm getting it entirely wrong but i can't seem to understand why. None of the blur assessment are correct at all. Wonder if anyone can give me any tips on getting the ...
0
votes
1answer
14 views

PSET4 Sepia If Statements

Hi can i ask why the if statements does not execute in this code? I tried running the program and saw that the if statements were not executed. void sepia(int height, int width, RGBTRIPLE image[...
0
votes
0answers
19 views

Pset4 Filter (more) compiles but fails almost all of check50 :(

Check50 link & code below All compiles but just can't get check50 right, I feel like there must be a common mistake between all of the functions as they all seem to get the first 3 lines of pixels ...
0
votes
0answers
21 views

PSET4 Blur Filter, blurs images correctly but check50 fails all blur checks

Not sure what I am doing wrong, I tried casting double to the blurhelper function and check50 still says it is wrong. void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE(*...
0
votes
1answer
17 views

What is wrong with my filter blur?

Been stuck on the blurring part for ages... I've ran out of ideas and motivation to debug at this point after spending an eternity cutting down my spaghetti codes to pappardelle. Any help/hint/...
0
votes
1answer
43 views

pset4 problem with blur, can't find what's wrong

I can't seen to find what is wrong with blur in my code. My code seems fine and it compiles too but the image doesn't get as blurred as it should. I've surfed through almost all the blur related ...
0
votes
3answers
88 views

Pset4 recover: Images recovered but check50 failed

I am currently stuck on this problem set, as it seems like I am able to recover the 50 jpgs but I am failing the check50. I am not sure what I am doing wrong and would appreciate some help. :( ...
0
votes
2answers
41 views

PSET 4 Recover, don't know what's causing seg fault

My code has been suffering from a seg fault, I followed the logic from the walkthrough pseudocode but unfortunately I cant seem to fix the issue. #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
48 views

Recover compiles fine, does not 'recover', and fails Check50

Any ideas where I'm going wrong? I seem to load all of the recovery data into image "000.jpg", never climbing out until I reach the end of the file. However, I cannot understand why this is so. ...
0
votes
1answer
45 views

PSET 4 - Filter: Anyone able to help me on Edges?

I'm having a lot of trouble figuring out how my code for edges is failing so badly every time. Any help on this would be greatly appreciated! Here is what I'm getting back from check50: :( edges ...
0
votes
1answer
28 views

Code only detects one jpeg in pset4 recover problem

my code for pset4 recovery only detects one jpeg signature. Here's my code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <...
0
votes
0answers
16 views

PSET4 - Filter (Less) Blur - Keep getting :( blur correctly filters middle pixel expected “127 140 149\n”, not “118 131 140\n”

void blur(int height, int width, RGBTRIPLE image[height][width]) { //A box blur //take the average of the surrounding pixels (1 row and 1 column away) //Store all the surrounding and find ...
-2
votes
1answer
41 views

While loop for recover pset4

I need a plain English explanation of how the while loop operates for the fread statement. After reading in the first 512 bytes, how does it loop to the next 512 bytes till it gets to the last block?
0
votes
1answer
34 views

segmentation fault in recover probably due to sprintf

#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc != 2) { return 1; } FILE *memory_card = fopen(argv[1], "r"); if (!...
0
votes
0answers
21 views

CS50 Pset4 Filter Blur less comfortable

I've tried getting blur done for some time now and I just can't get the border pixels to calculate properly as they continue to go out of bounds. I have noticed that at the start of the program ...
0
votes
0answers
16 views

The blur is not updating when it should be

The suspected incorrect of my code is here: for(int i =0;i<height;i++) { for(int j = 0;j<width;j++) { image[i][j] = copy[i][j]; } } or ...
0
votes
2answers
53 views

Q: PSETt#4 - Filter (more) - Edges

I'm stuck with the problem pset4 edges. The checks for the middle pixels work. But not the corner's pixels. :( edges correctly filters pixel in corner expected "76 117 255\n", not "76 117 66\n" It ...
0
votes
1answer
40 views

CS50/PSET4/RECOVER- Error- “Can't open card.raw: file format unsupported”

Keep getting "Can't open card.raw: file format unsupported" error when running the code. Not sure what I'm doing wrong. #include <stdio.h> #include <stdlib.h> int main(int argc, char *...
0
votes
1answer
34 views

PSET4 Recover, Dynamic File Names

So far I've gotten to the point where I can recover one image. I'm to the point where I need to find a good way to make dynamic variable names. I thought of one way to do it, but it seems rather ...
0
votes
1answer
26 views

CS50 PSET4 Edge calculates correct values on all tests unless the correct value is 255

I am having problems with CS50 PSet 4 - Edge. The method passes the middle pixel test (which has no value of 255 on any channel) but on any other test all the values in each channel are correct ...
0
votes
1answer
33 views

PSET 4 blur function only passing one test case

void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE copy[height][width]; int counter = 0; int red = 0; int blue = 0; int green = 0; for(int i=0; i<height; i++) { ...
0
votes
1answer
64 views

PSet4 Recover, only finds 22 corrupted photos, doesn't pass Check50

Originally, my code always returned Segmentation Faults whenever running it. I used printf statements to find and fix the segmentation faults, but now it is only finding 22 out of the 50 photos and ...
0
votes
1answer
44 views

pset4 filter blur

I have written the following code for blur . // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { for ( int h=0 ; h<height ; h++) { for ( int w=0 ; ...

1
2 3 4 5
31