Skip to main content

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
1 answer
951 views

CS50 Problem Set 4 Edge Filter

the output of my program seems fine. When i run Check50 though i get two error messages: :( edges correctly filters 3x3 image expected "76 117 255\n21...", not "76 117 255\n21..." :( edges ...
0 votes
1 answer
359 views

CS50: Pset4: Filter-More : "filter compiles :expected exit code 0, not 2" while running Check50

My code compiles fine with no errors but when running check50 it fails at the second check saying filter compiles: expected exit code 0, not 2. Main returns 2 when more than one argument for filters ...
0 votes
1 answer
109 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
1 answer
40 views

I'm stuck with updating the resize variables, I get segmentation fault

#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper usage if (argc != 4) { fprintf(...
0 votes
1 answer
41 views

PSET4 Resize Only works for half an image

So I thought I finished but the image only half way is written. Not sure what I did wrong but the image scales but only the top half. I tried both ways I could think of for the loop but decided using ...
0 votes
1 answer
66 views

PSET4 recover! dynamically allocated array does not seem to work

Hope all is well. This is probably a stupid question but I am going to ask it anyway. I have finally finished Recover (PSET4). I initially dynamically allocated an array as follows to store my 512 ...
0 votes
1 answer
44 views

Pset4, resize, vertical scaling fail

I have refer to some posts with relative questions. Refer to this post: Pset4, resize, fseek, vertical scaling I found that the BMP header part this post declare another variable for new bmp file as ...
1 vote
1 answer
9 views

PSet4, Filter-less blurs but gets a lot darker and doesn't match output

I'm having an issue with the blur filter; when working with Duck to understand how to structure my code, I was able to come up with a solution, but the output image was darkened and blurred up until ...
0 votes
1 answer
53 views

When passing a pointer of an array to a function, does the function read through the array until it encounters '\0'?

Below is a piece of the code from copy.c in pset4. I am interpreting it in the following way: the name of the input file is being entered as a string to be stored at argv[1]. a pointer to argv[1][0] ...
0 votes
1 answer
73 views

pset4 recover: too many JPEGs found

guys! I was solving recover, but my program finds way too many JPEGs. I believe that this is because of the following lines: // starting bytes of jpeg are in [lower, upper] uint8_t lower[4] = {0xff, ...
0 votes
1 answer
45 views

Collatz Function Iteration

Guys help here I'm so lost as how to answer this question, I'm infact clueless...Find the two smallest different input numbers x,y (with 0<x<y), for which the COLLATZ algorithm takes equally ...
0 votes
1 answer
62 views

Resize Adding Too Much Padding

I'm really struggling with resize on pset4. My loop is adding too much padding, I think by a factor of the scale. I'm still working on the horizontal stretch portion of the program. I'm pretty sure ...
0 votes
1 answer
43 views

Check50 error in pset4 recover exercise

I have the following problem, I finished the exercise "recover" in pset 4 and all the recovered images are fine (check them one by one), but the tool "check50" tells me that the program does not ...
0 votes
1 answer
26 views

Any idea why i am getting this error in pset4

#include "helpers.h" #include <math.h> // Convert image to grayscale void grayscale(int height, int width, RGBTRIPLE image[height][width]) { // comb trw each row for (int i = 0;...
0 votes
1 answer
57 views

pset4 recover file name declaration

char jpgname[8]; // Correct declaration char *jpgname = "000.jpg"; // Incorrect declaration . . sprintf(jpgname,"%03i.jpg", fileNum); // Segmentation fault seemed to occur on this line if the ...
0 votes
1 answer
75 views

Pset4 - Resize problem with vertical scaling

int main(int argc, char *argv[]) { // ensure proper usage if (argc != 4) { fprintf(stderr, "Usage: ./copy infile outfile\n"); return 1; } // remember filenames int n = ...
0 votes
1 answer
59 views

Pset4, whodunit, Just created a bmp with no color

My code is following. Feel puzzled to generate wrong result.. ``` #include #include "bmp.h" #include #include int main(int argc, char *argv[]) { if (argc != 3) { fprintf(stderr, "...
0 votes
1 answer
32 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; ...
0 votes
1 answer
27 views

Segmentation fault, speller trie pset 4

I'm getting a segmentation fault where i set node *new = malloc(sizeof(node)) I don't understand why I'm getting this fault, i am just allocating new untouched memory with malloc. // Implements a ...
0 votes
2 answers
558 views

PSET4 Resize (More) - Downsizing, which pixels to skip, where to readup?

I'm doing PSET4 (More) and fixing the downsizing portion. Given a 8 x 8 pixel image. Downsizing to a 4 x 4 pixel image. n = 0.5 So I'm starting with 64 pixels. New image must have 16 pixels. I ...
0 votes
1 answer
7 views

What is the return value of fread when it reads slack space?

This is my code for recover.c in pset4: #include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc != 2) { printf("...
0 votes
1 answer
105 views

Still having problems with recover.c, doesn't pass all the checks

Here is my code: include include include include int main(int argc, string argv[]) { // ensure proper usage if (argc != 2) { fprintf(stderr, "Usage: ./recover infile\n"); ...
0 votes
1 answer
85 views

Recover from getting 8 images to now just 1 image and terminal hanging

Ok now for the last 48 hours I have been trying to make recover work. First I made a program that got only 8 correct images. I posted my problem in this link and got a response and understood how my ...
0 votes
1 answer
69 views

Pset 4 resize: Image remains same size and image changes

I have an issue that I have been tearing my hair out for a week about. My code does not resize the image and it doesn't keep the image the same. What is the problem with my logic? /** * Copies a BMP ...
1 vote
1 answer
403 views

pset 4 filter edge not working

I am having issues with my implementation of edges. I decided to make a 'border' around the edges of the image made up of zeros (did this in a copyImage array). I get correct outputs for some of the ...
0 votes
1 answer
49 views

PSET4 Recover Segmentation Fault, please help

I hope everyone is doing well during this difficult time, my prayers to those been affected by it. I have difficulty debugging the segmentation fault here and the cs50 debugger is not too helpful on ...
1 vote
2 answers
110 views

Cleaning up PSET4 Blur

I have successfully finished the blur effect on PSET4. Here is a small smattering of the code if(i - 1 >= 0 && j - 1 >= 0) { red += OgImage[i-1][j-1]....
0 votes
1 answer
76 views

Problem with Recover (Pset4)

everyone. I've been struggling with the Recover problem of Pset4. I really don't understand why I'm getting the following error message when applying the Check50 control: *Results for cs50/problems/...
0 votes
1 answer
13 views

check50 says program isn't free of memory errors while valgrind says no memory leak is possible in recover.c

There is only one use of malloc in the program and it is freed before the program exits: #include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) {...
0 votes
1 answer
118 views

bfSize different colors resize pset4

I just cannot stop getting funky different colors when I resize, and I see it must be some padding issue. I used the specs and peek to compare my file student.bmp with the staff.bmp. It shows in red ...
0 votes
1 answer
90 views

Speller - Program has memory errors, but Valgrind claims all heap blocks were freed

:( program is free of memory errors | pset5 Speller I have invalid reads at lines 148 and 153 of my code (commented out below): bool unload(void) { // CS50 for (int i = 0; i < 26; i++)...
0 votes
1 answer
69 views

Why does my program return a blank jpeg?

I have started recover.c in pset4. I have decided to approach the problem step by step, so first task is recovering the first jpeg. enter code here FILE* file = fopen("card.raw", "r"); ...
0 votes
1 answer
220 views

pset4 recover doesn't pass check50

i have gone through the answers already posted but they don't seem to handle my exception. this is my code: /** * recover.c * * Computer Science 50 * Problem Set 4 * * Recovers JPEGs from a ...
0 votes
1 answer
544 views

Understanding Pset4 Recover Valgrind Errors

My code for Recover is passing all the tests in Check50 except for the final one on memory errors. When I run valgrind ./recover I get this: When I look into the details of why I'm not passing ...
0 votes
1 answer
54 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
1 answer
54 views

problem with resize cs50check giving out red errors in some test

the program is working correctly resizes perfectly (atleast i think) but cs50 check gives out an error on todos on some test please guide https://sandbox.cs50.net/checks/...
0 votes
1 answer
50 views

recover.c check50 not getting through

#include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef uint8_t BYTE; int main(int argc, char* argv[]) { BYTE buffer[512]; // made a buffer FILE* input = fopen("...
0 votes
1 answer
565 views

To those who struggle with pset4’s filter-more’s edge detection filter

I’m sure it is obvious for some people, but it wasn’t for me) If your code isn’t working the way it should, you can create new .c file and put there your logic from edge detection function. You can ...
0 votes
1 answer
88 views

PSET4 Recover Output Ptr Closing/JPEG Writing

I have a script that mostly works, I think, but I cant get the file writing to work. I have seen some others use a flag for calling when to close the output pointer but I cant see why this way wont ...
0 votes
1 answer
75 views

Pset4. Resize, less comfortable. Don't understand why code is working

I was having issues with my headers because I chose to create a separate header file for my new header changes. However, my code was not passing the check50. Upon researching and questioning, I found ...
0 votes
1 answer
324 views

resize runtime error pset4

My code compiles, but when I execute this I get: runtime error: index 4 out of bounds for type 'RGBTRIPLE [newbi.biWidth]' Where does 4 come from? Is it the number of arguments?? Thanks for any help....
0 votes
1 answer
41 views

Resize acting weird in some cases storing 1 pixelXpixel less

I have spent lots of time reading to find someone with alike problem, but simply couldn't. Would be so much thankful for any hint! My resize is acting weird, despite the varriables store correct ...
0 votes
1 answer
53 views

pset 4- check function not working if I close dictionary file

here are my load and check functions: bool load(const char *dictionary) { nw=0; int k = 0; while(dictionary[k] != '\0') { dictionary2[k]=dictionary[k]; k++; } ...
0 votes
1 answer
46 views

What is the FILE structure that we use for fopen?

What exactly is the FILE structure that we use for fopen? How does it work exactly?
0 votes
2 answers
51 views

Hello guys... Good day. I'm currently on the pset 4 (recover). program is working well, but the (valgrind) requirement in the check50 isn't checking

#include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef uint8_t BYTE; int main(int argc, char *argv[]) { // Check that command-line arguments is 2 if (argc != 2) ...
0 votes
2 answers
54 views

Some comprehension questions now that I've fixed my code

So i struggled probably a little less than some did with recover.c, and was able to fix my problems with the help of other's questions on this stackexchange, but although i was able to get my code ...
0 votes
2 answers
35 views

pset4 resize I don't know why my code is not working

#include <cs50.h> #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { // check if users put in correct command-line arguments if (argc != 4)...
0 votes
1 answer
151 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
1 answer
71 views

PSET4 Recover timing out

My code works for the card.raw that is given part of the problem set. However, it times out when I use check50. Does anyone know why even though the code compiles rather quickly for the card.raw? Or ...
0 votes
1 answer
68 views

pset4 Recover check50 error lack of image

I've finished my code and have recovered the photos, but in check50 it shows an error saying :) recover.c exists :) recover.c compiles :( handles lack of forensic image \ expected standard error, ...

1
2 3 4 5
37