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
0answers
16 views

Recover.c fprintf failing on the 35th file

So on the recover.c program, my program works to recover the first 34 images, but it segfaults on the 35th. I've determined that it has to do with the fprintf function, but it worked the first 34 ...
0
votes
1answer
18 views

I know that my recover is wrong, but I'm not sure what steps to take-

I 'm getting a segmentation fault for my recover code. I know that it's wrong, and I think that this boils down to me not really understanding how to apply pointers/file functions. Maybe you could ...
0
votes
1answer
8 views

Implicit declaration of function of a declared prototype PSET4

I have this error code: helpers.c:56:13: warning: implicit declaration of function 'swap' is invalid in C99 [-Wimplicit-function-declaration] swap(height, width, image, i, j); ^ helpers.c:62:6: error:...
0
votes
1answer
19 views

Pset4 Filter Less Blur Runtime Error

Below is my Blur function, which does actually work, yet still returns 9 runtime errors all relating to the right hand side of the image (or the width-value edge). I added a couple of printfs to check ...
0
votes
1answer
23 views

CS50 PSET4 (Less) Blur Failed 3x3 & 4x4

This code won't win any style contests, however comma all Check50 test pass except the 3x3 and 4x4. I made a copy of the image, blurred original values, and copied new values to the original image at ...
0
votes
1answer
11 views

Pset4: Recovery- Empty JPEG files

My code compiles fine and the syntax seems fine, but the 50 JPEG files it produces are all empty, except 001.jpg and 019.jpg which both show a small top portion of the image. Could someone kindly tell ...
0
votes
1answer
27 views

Help on blur function. Correct logic but wont work

So after I passed pset3, I thought things would go easier since my friend said that filter wasn't as complicated as Tideman. Now, I’m doing the blur filter part and stuck on its computation especially ...
0
votes
1answer
27 views

I can only find 13 images using recover

I am aware that the same question has been asked before: PSET4 Recover only finds 13/16 images However, as far as I could try given this answer, I could not fix my function so it would successfully ...
0
votes
1answer
23 views

Pset4 - recover - issue with file pointers

I'm working on recover and I think I'm nearly there but I can't resolve an issue with file pointers. When I'm compiling I'm getting two errors both say error: use of undeclared identifier 'ptr'. I ...
0
votes
1answer
23 views

Help on Pset4-recover, Segmentation Fault

Here is my code: #include <stdio.h> #include <stdlib.h> #include <stdint.h> //remember: free malloc + fclose files typedef uint8_t BYTE; int main(int argc, char *argv[]) { //...
0
votes
1answer
8 views

PSET4: filter(less) sepia limit to 8 bits

I'm working on pset4 filter(less) and have a question regarding limiting the RGB value to 8 bits. I'd like to know what happens when a value of more than 8 bits is stored in BYTE (uint8_t). Initially, ...
0
votes
0answers
24 views

FILTER WORKS FINE, BUT BLUR FAILS 3x3 and 4x4

The code works fine, but it fails blur filters a 3x3 and 4x4 image. I would like a help on why it correctly blur a middle pixel, but fails those two. Apparently, the wrong pixels are either on edge (...
0
votes
1answer
17 views

Seg Fault in Writing to JPG

I am working on PSET4 Recover, and got to writing to the output file, but for some reason, it SegFaults when I try writing to a jpg. The error, as far as I can tell, occurs in the While Loop in the ...
0
votes
1answer
21 views

Can't seem to wrap my head around what the Bitwise AND operator does in Pset4 vs. && AND operator

I just watched the Recover video and I saw them mention bitwise arithmetic, but I am not exactly sure what that means nor what it does. I saw another forum post explain it but that also didn't really ...
0
votes
0answers
24 views

Trouble filtering center pixels in pset4 filter blur

I am SO close on reflect but am still getting a few final errors. My code for pixels on the edge and in the corners seems to work fine. However, there is an issue with my code on the center pixels and ...
0
votes
1answer
15 views

Runtime error in pset4

I'm currently working on filter.c, and I'm struggling with the blur segment of it. I tried to write a code (I'm aware it's a mess of hard-code, but it's an attempt!), but I keep getting this error: ...
0
votes
2answers
53 views

Pset4 Recover: succesfully recovers first and second image, unsure as to why no other image is recovered (spoiler)

I must admit I'm having particular trouble in this assignment. Maybe it's the amount of new concepts. I think I have the idea down but I must me missing an error regarding the loop. I've tried ...
0
votes
1answer
28 views

pset4 recover - how can I get last few bytes to JPG

I've finally gotten recover.c to the point where it compiles. When I run it, it gives me this error message: munmap_chunk(): invalid pointer Aborted But it also generates all fifty of the pictures! ...
0
votes
1answer
37 views

pset4 Filter (more) Edge Detection help

void edges(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE copy[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) {...
0
votes
1answer
20 views

Pset4: filter greyscale UndefinedBehaviorSanitizer (not due to incorrect order of height and width)

I've seen all the other questions and answers regarding this specific error. Thankfully, or not so, my error was not due to the order in which I looped through the image. Here's my code: void ...
0
votes
2answers
25 views

Valgrind - 2 memory leaks | Recover.c | Pset-4

Valgrind encountered two errors in the following code. I'm not able to get why is this happening even when I close files and free allocs. Please help if you can. #include <stdio.h> #include <...
0
votes
1answer
21 views

Pset4 reflect works but doesn't pass check50

I am so close on the reflect function for pset4. When I run the program it appears to work properly, but it doesn't pass check50. Does anyone know what I am doing wrong? void swap(RGBTRIPLE *a, ...
0
votes
1answer
30 views

CS50 PSET 4 REFLECT FAILS CS50

This code does indeed reflect the image, but, there is a slight line in the middle. And CS50 fails it completely // Reflect image horizontally void reflect(int height, int width, RGBTRIPLE image[...
0
votes
1answer
53 views

pset4 filter blur problem

the images is blurry but the check gives errors (it only blurs correctly the edges and corners apparently ...): :( blur correctly filters middle pixel expected "127 140 149\n", not "...
0
votes
1answer
25 views

CS50 Pset4 Filter (More comfortable) Edges Function

I am trying to code CS50's Pset4 Filter (More comfortable)'s edges function, but I keep on getting a different value. This is the link to the video explaining what I am trying to do in this function, ...
0
votes
2answers
34 views

Logic for reflect function in pset4 filter

I'm working through pset4 filter and the code for the reflect function. I'm still getting errors so clearly there's some kind of issue with my logic. When I try to apply filter to an actual image, I ...
0
votes
1answer
24 views

pset4 filter: blur check50 shows same values, but is returning an error

The blur image seems to be working and according to the error I am seeing, it looks like it is getting the right values, so I thought it might be a rounding error, but I have tried every combination ...
0
votes
1answer
27 views

pset4: recover segmentation fault

The code compiles fine but when running ./recover i keep getting a seg fault. i tried valgrind but still can't seem to get what the problem is exactly. #include <stdio.h> #include <stdlib.h&...
0
votes
1answer
30 views

Recover jpeg runs only in debug

When I run my code in debug mode it works fine and creates 50 jpg images. When I run it like ./recover card.raw it waits forever without an error code. When I submit it, it times out. What am I doing ...
0
votes
1answer
10 views

Find hex values inside a string in C?

I have a long string "given_string", and I'm trying to find hex values within that string. Here's a simplified example: /* Find a sub-string in a given string: */ char * given_string = &...
0
votes
2answers
19 views

CS50 pset4 filter reflect issue

i am missing something here...but not sure what... it doesn't work on normal images... check50 passes for 1X2 and 1X3 images but fails for 3x3 and 4x4 images (so i guess it is an issue of iterating ...
0
votes
1answer
18 views

Understanding the contents of the raw file

I'm playing around with file pointers in preparation for the Recover Problem. I'm trying to understand something here. I can't actually open up the raw file to read on my IDE. And neither can I read ...
0
votes
0answers
21 views

How do I fix my code for PSET 4 blur?

What I tried to do was go to each pixel and see if any neighboring ones existed. If they did, I saved the neighboring pixel's colors. Then I ran a loop to add up all the values in that specific color ...
0
votes
1answer
27 views

Stuck on recover

I am currently stuck on recover and cannot understand the fread function and how does it behave. I have watched all the shorts and explanations but i still don't get it. I also wasn't able to find any ...
0
votes
1answer
38 views

Pset 4 filter - blur almost works but has a few errors and I just can't figure out why

I've tried changing everything I can think of, but I can't figure out why this isn't working. #include "helpers.h" #include <math.h> int cap (int x); RGBTRIPLE rowend (RGBTRIPLE x, ...
0
votes
0answers
26 views

Getting UndefinedBehaviorSanitizer on pset4 filter blur (less comfortable)

I've tried doing this problem a few ways (without success). This time, I wrote the following code: #include "helpers.h" #include <math.h> int cap (int x); RGBTRIPLE corner (RGBTRIPLE ...
0
votes
1answer
33 views

Segmentation Fault with Problem Set 4 (Recover)

I am getting a segmentation fault when running my program that only allows me to print out 1 broken image. However, when I run the program with valgrind it prints out 49 of the 50 photos, and the only ...
0
votes
1answer
14 views

getting undefined behaviour sanitiser deadly signal error which crashes everything when trying t run greyscale filter on pset4!

The below image shows my code and all the errors that come when I run it. I have to exit the terminal and start again to do anything! I don't understand what is wrong with the code. I have looked ...
0
votes
0answers
30 views

For pset4/recover i keep getting an error despite the pictures recovering when i run the program

could someone please identify whats wrong with my code. im a beginner and completely lost.
0
votes
0answers
8 views

Issues with PSET4 Filter Edge Detection

I've been testing my edges code for ages now but I can't seem to figure out the problem. When I run the code on the sample images the images look like they have been processed properly but when I put ...
0
votes
1answer
53 views

PSET4 - Need help with Recover problem

I am stuck in this problem, when I run it I keep getting a segmentation fault. I think that the bug in my code is in the while loop. In the walkthrough of the problem it was suggested to check if ...
0
votes
1answer
18 views

i don't know what is wrong when i run the program the output is all zeros

void blur(int height, int width, RGBTRIPLE image[height][width]) { double red_sum ; double green_sum ; double blue_sum ; double counter; RGBTRIPLE new_image[height][width]; ...
0
votes
2answers
36 views

Help with pset4 filter edge detection function

I have some problems with the edges function. The code compiles fine and all but the result looks like this: https://imgur.com/a/S2MQLom The edges of the image and one third of it don't look as ...
0
votes
1answer
43 views

Pset4 Recover - Unexpected Output

My program outputs JPEG files, but not enough and they are corrupted. It has been a long day and it is Friday. Any kind of push in the right direction would be fantastic thank you. #include <stdio....
0
votes
1answer
26 views

PSET 4 Recover - Copy-Pasting 1 Line from 1 Place to Another Causes Huge Error

This Code Below Worked Fine, I got Passed!! #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> typedef uint8_t BYTE; int main(int argc, char *...
0
votes
1answer
24 views

Pset4 Filter Help

So far I only have gray scale done, but whenever I try to run it to see if it'll work with ./filter -g infile.bmp outfile.bmp it gives me an error message saying Could not open infile.bmp. It works ...
0
votes
1answer
31 views

pset4 filter - blur function only filters image corners

This is my second attempt at this problem, and a full rewrite; I tried once before to be as eloquent as I could, and it was just totally wrong and bizarre. So I just tried to make this one as readable ...
0
votes
1answer
25 views

Sepia Filter won't work for more complex 3x3 and 4x4 images

:) sepia correctly filters single pixel :) sepia correctly filters simple 3x3 image :( sepia correctly filters more complex 3x3 image expected "25 22 17\n66 5...", not "25 22 17\n66 ...
0
votes
1answer
44 views

PSET4 Recover: Where do my ###.jpg files end up?

My code looks right, and after some segmentation errors, I finally fixed that, but I've run into a problem: My created ###.jpg files don't actually seem to be written to anywhere, as in I can't find ...
1
vote
1answer
55 views

Week 4: Recover (invalid stdio handle)

As I'm sure you're aware, the goal of this assignment is to recover a number of deleted jpeg files from a provided memory card image. My code compiles and executes, but I'm receiving the error "...

1
2 3 4 5
32