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
1
vote
1answer
30 views

CS50 Pset4 Sepia

I have been working on PSET4 and understood the code and the tasks fine. But my compilation does not change the image and I cannot figure out why it will not work for the life of me. I have checked ...
0
votes
1answer
22 views

PSET4 - Recover - Segmentation fault, not sure what's wrong

Can't understand what's wrong in my code: it's compiling but not creating jpgs, the check says "failed to execute program due to segmentation fault". Please help to understand - THANKS IN ...
0
votes
1answer
28 views

Regarding PSET4: Recover is compiled but only 26 files are recovered but unable to open images

#include <stdio.h> //call for sprintf() #include <stdint.h> //call for typedef uint8_t BYTE #include <stdlib.h> //call for sizeof() and NULL typedef uint8_t BYTE; //...
0
votes
1answer
41 views

PSet 4 Filter(less) Sepia - Why is my output image slightly red tinted?

At first, I forgot to cap the RGB values at 255 for sepia, and it resulted in white pixels being blue. But other areas were fine(proper sepia). So additionally, I added the ternary operators to check ...
0
votes
1answer
35 views

pset4 recover.c last image does not match

I've doing recover.c from pset4. When I ran check50, all images except for the last one. I guess it's probably the problem of feof function. But I don't know how to edit my code to make it works //...
0
votes
0answers
16 views

PSET 4 - Blur - IF Statement

I can't seem to understand why the if-statement doesn't work to filter out the cells outside of the image's rows/columns. see the full code below, I left out the part where I copy it back into the ...
0
votes
1answer
28 views

pset4 recover creates 50 images but bytes don't match up

My code creates the 50 files, all of them starting with the correct JPEG signature, however the rest of the bytes don't match up. In other words, first 4 bytes are correct, the following bytes are ...
0
votes
0answers
19 views

I keep getting the error: linker command failed with exit code 1 (use -v to see invocation) when I'm compiling my code for filter: blur in ide

I seem to get this error over and over again when i compile my code for filter: blur by typing "make helpers". I don't know if it's because of my code. This error did not appear when I ...
0
votes
2answers
51 views

My recover doesn't stop executing once it starts

Not actually sure what is wrong with my code but it doesn't end when it's executed. I tried adding return 0 so it would end but it's not working. code: #include <stdio.h> #include <stdint.h&...
0
votes
1answer
45 views

PSET 4 Recover.C wrong exit code?

Currently getting the following errors when working on pset4 for the class CS50. Not sure why my exit code is none? Please let me know if you guys know what the issue is. Thank You. :) recover.c ...
0
votes
1answer
23 views

buffer array full of \000, pset 4 recover segfault

I am experienceing a problem where nothing is beign read into a buffer array, but for the life of me I am unable to figure out why. I have read through other threads with users experiencing the same ...
0
votes
1answer
34 views

Pset 4 filter blur function - only works with corner pixel

requesting help for my blur function. For each pixel, i have split it into 3 for loops. One calculating the row above, same row, and row below. In each loop , if the row is smaller than 0 or equal to ...
0
votes
1answer
33 views

How to conserve original values in blur function? (pset 4)

Here's my code inside the blur function (in pset 4, Filter-Less): int redSum; int greenSum; int blueSum; int n; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { ...
0
votes
1answer
35 views

Why does `size` = `0` occur?

I've been trying PSet4's Recover. I've been trying to obtain the size of the entered file (card.raw) but unfortunately size gives and output of 0. Here's the code that I've made to find the file's ...
0
votes
0answers
31 views

How do I interpret Valgrind to fix this program's segmentation fault?

I was attempting PSet 4's Recover but kept running into a segmentation fault. I tried using Valgrind to debug it but I have no idea of how to interpret the error message. My code: #include <stdio.h&...
0
votes
1answer
28 views

Some values in my 'edges' don't pass check50

the rightmost values in the matrix in check50 is wrong but the other values are correct. I'm not really sure what's wrong. code: void edges(int height, int width, RGBTRIPLE image[height][width]) { ...
0
votes
1answer
36 views

Pset4 recover getting Segmentation error

#include <stdio.h> #include <stdlib.h> #include <cs50.h> int main(int argc, char *argv[]) { // file opened FILE *file = fopen(argv[1], "r"); // user types two ...
0
votes
0answers
20 views

Help with PSet 4 Filter (More) Edge

I've been stuck on the Edge part of Filter (More) for a few days now. Check50 tells me that none of the pixels return the right values but I can't seem to find any problem with the code. Here's my ...
0
votes
1answer
21 views

Not getting the edge function to work

Please find my code for the edge function below, I'm getting all errors on check50 but can't understand what's wrong. // Detect edges void edges(int height, int width, RGBTRIPLE image[height][width]) {...
0
votes
1answer
64 views

Recover.c - Code Creates JPG files but it doesn't doesn't match expected output

#include <stdio.h> #include <stdint.h> #include <stdlib.h> typedef uint8_t BYTE; int main(int argc, char *argv[]) { //user didn't enter one argument or enters more than one if (argc &...
0
votes
1answer
45 views

Problem Set 4 Blur --- incorrect output

I am currently working at the blur filter. While the other task were pretty easy, this one ist very much difficult. I have spend hours looking for the mistake - but without success, I tried to do it ...
0
votes
1answer
41 views

PSET4 filters helpers.c

I need some help with pointers, mostly. I've malloc'd a BUFFER pointer to the struct data type RGBTRIPLE. Though I can't access its properties. // Reflect image horizontally void reflect(int height, ...
0
votes
1answer
42 views

Need help solving blur with c

Code: void blur(int height, int width, RGBTRIPLE image[height][width]) { //temporary image to swap RGBTRIPLE temp_img[height][width]; for (int g = 0; g < height; g++) { for (int h = 0; h < ...
0
votes
0answers
32 views

check50 is not working with pset4 filter

I've been trying to check problemset4 filter-less but check50 is not working The username and password is correct and I have visited submit.cs50.io as the message says and I was logged in there but ...
0
votes
1answer
52 views

PSET 4 Recover.c - Segmentation fault

The code compiles perfectly. However, it triggers a segmentation fault which I imagine is due to a wrong use of pointers. This is the code: #include <stdio.h> #include <stdlib.h> #...
0
votes
0answers
17 views

CS50 Reflect Pset4 Runtime error

my code for reflect is this void swap (RGBTRIPLE *a, RGBTRIPLE *b) { RGBTRIPLE temp=*a; *a=*b; *b=temp; } // Reflect image horizontally void reflect(int height, int width, RGBTRIPLE image[height][...
0
votes
1answer
27 views

Why is reflect filter not working Pset4?

Here is my code. I have overcomplicated it. for (int i=0;i<height -1; i++) { for (int j=0;j<width- 1;j++) { int value[3]; value[0]=image[i][j].rgbtBlue; value[1]=image[i][j]....
0
votes
1answer
28 views

Images shifted with no 049.jpg in recover

My code compiles and runs and the images load and seem fine BUT it skips the first image and ends at 48. There IS an image named 000.jpg that is output but that image under the name 000.jpg from what ...
0
votes
2answers
31 views

edges completely fails check50

So I finished my edges function and it's failing everything for check50 and I can't understand what I did wrong. Any help would be greatly appreciated. Functions related to edges: // Sets new RGB ...
0
votes
2answers
143 views

Pset4, the first problem "Filter". How can I define the grayscale function recursively?

I have a question about problem 4, assignment 1 Filter, where we have to define the grayscale function. So it is actually not difficult to define this function with a loop in a loop. But I am trying ...
1
vote
2answers
63 views

What's my error?

I am having some errors with my code in check50. All of my code is on this gist. Grayscale - expected "28 28 28\n", not "27 27 27\n" in without whole number average. I am using ...
0
votes
1answer
22 views

how can I rewind the fread() funtion as byte

is there a way to fread() the same bytes you just had read? fread(buffer, 512, 1, inptr); if (header(buffer) == true) { //execute these lines do { //execute these lines } ...
0
votes
1answer
39 views

Pset 4 Filter(less) Blur

I'm having an issue with the counter variable of my code. I wrote a printf to see if it returns 4, 6, or 9. Which is what it should do, if my IF conditions are correct. Unfortunately it does not ...
0
votes
1answer
47 views

CS50 Recover (pset4). Images dont seem to load

my program compiles successfully but it doesn't seem to produce any images at all. I tried using debug50 and it seems like the if condition for buffer[0] through to buffer[3] isn't fulfilled, or the ...
0
votes
1answer
43 views

How can I create a loop to read end of the card.raw file?

I'm using the basic expressions have been taught in the short videos but probably I'm implementing them wrong, especially I believe I'm using the wrong data types for my variables :/ My loop ...
0
votes
1answer
37 views

I don't understand the error message I'm getting

I don't understand the error message, and i've been trying to modify the code to fix the error but it still appears. // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { ...
0
votes
2answers
65 views

CS50 Recover (Pset4). What exactly is causing the segmentation fault?

CS50 NEWBIE here. Program successfully compiles but I keep getting a segmentation fault error when trying to run it. After some debugging, I think the problem has something to do with trying to close ...
0
votes
1answer
78 views

code is free(): invalid pointer and Aborted, and I don't understand why

at first it worked. But i make style and add more coment and it was broken. It makes all images but in the end: free(): invalid pointer Aborted and i don't understand why. I rewrite code and all work....
0
votes
1answer
52 views

why does it fail check50 for the last image?

#include <stdlib.h> #include <stdio.h> typedef unsigned char BYTE; int main(int argc, char *argv[]) { if (argc != 2) { return 1; } FILE *infile = fopen(argv[1], &...
0
votes
1answer
31 views

Pset4Ffilter - Starting Off

I'm doing the pset4 filter (less comfortable),but I just don't know where to start. Can someone pleases give me some starting off tips?
0
votes
1answer
54 views

Recover Week 4 Assignment--Code appears to work beautifully but check50 says no

My code works as I get all 0-49 images that look beautiful to me. After days of working on this, I really would appreciate any advice as to why the checker is saying my code failed the last three ...
0
votes
0answers
25 views

Week 4 recover seg fault

#include <stdio.h> #include <stdlib.h> #define BYTE 512 #define NAME 8 int main(int argc, char *argv[]) { //check for valid input if(argc != 2) { //Promt user for valid input printf("...
0
votes
1answer
36 views

So i have written the recovery code which compiles but all the images are Invalid and Unsuported format

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { if (argc < 2) { printf("Usage: ./recover image\n"); ...
0
votes
1answer
54 views

PSET4 Recover: Check50 shows error

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> typedef char* string; typedef uint8_t BYTE; int main(int argc, char *argv[]) { if (argc != 2) { ...
0
votes
0answers
45 views

Problem with filter (pset 4): Blur and edge

All the filters on the filter program work well, but check50 is giving me a few errors, which I think, is due to rounding issues. But, I have checked and re-checked the code for those errors, and ...
0
votes
1answer
48 views

PSET4 Filter Blur by 4 nested for loops

I am trying to implement my idea on Blur function. My main assumption is to get this done using nested 4 for loops as follow: void blur(int height, int width, RGBTRIPLE image[height][width]) { ...
0
votes
1answer
36 views

pset4 recover error - timed out while waiting for program to exit

i am getting a timed out error but don t understand why...? also i can see all the pictures except the last one (049.jpg) ... #include <stdio.h> #include <stdlib.h> int main(int argc, ...
0
votes
1answer
32 views

Pset4 Recover JPEG images do not match

Getting closer on Pset4 Recover but still working through some issues. I am now generating jpegs (yay!) but they apparently do not match the original images. So I am getting three errors: :( recovers ...
1
vote
2answers
44 views

Blur only working with middle pixel

I've been stuck in this problem for a while, and the code only works when its inputted a middle pixel. Does anyone have a clue? I've searched everywhere for this particular issue, but I have only ...
0
votes
1answer
34 views

Pset4 Recover Problem With Seg Fault *Updated*

Getting closer on this now and am no longer getting a segmentation fault. However, my Jpeg images created by the program are not correct. I think part of the problem is that I am writing rather than ...

1 2
3
4 5
35