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
2answers
1k views

Why is my array of RGBTriple not working?

I know there are a lot of questions surrounding this topic. Read 'em, still having trouble. The common suggestion here for declaring an array of RGBTriples is something like the following: ...
0
votes
1answer
60 views

Too many pixels on "Resize", correct headers/image but does not pass check50!

I have a strange flaw in my program. Initially everything looks fine, it can resize any image correctly and the headers of the staff solutions and mine all match via "peek", so it seems that it makes ...
0
votes
1answer
258 views

Pset 4: Resized image completely green--padding problem?

So I'm struggling a bit with pset4. My resize program results in an outfile that is the correct size with an n of 4 (I used the xxd command to compare with large.bmp) so I don't think it's a header ...
0
votes
1answer
365 views

pset4 - recover -- File does not produce jpegs but I don't know why

I am stuck. It compiles but doesn't produce the jpegs. Any insight please? int main(void) { // open file for reading FILE* file = fopen("card.raw", "r"); // Open the file for reading // ...
2
votes
1answer
564 views

How do the headers in copy.c update on pset4?

I don't really understand the following code in copy.c: // write outfile's BITMAPFILEHEADER fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr); // write outfile's BITMAPINFOHEADER fwrite(&bi, ...
2
votes
1answer
89 views

Pset4 recover: Form of bytes when they're read in?

I am stuck on figuring out what form the bytes are in when they're read? I created a buffer of type char and I get one result when I read the bytes in. Then I created a buffer of type int and I get a ...
1
vote
2answers
986 views

Why does copy.c skip padding?

I'm having a bit of a hard time understanding certain lines of code in copy.c. For example below: // skip over padding, if any fseek(inptr, padding, SEEK_CUR); // then add it back (to demonstrate ...
0
votes
1answer
770 views

Is it even possible to isolate the colors in order to bring to the foreground "whodunit" ? [duplicate]

I have a question in psett 4's, "whodunit". Is it even possible to isolate the colors in order to bring to the foreground "whodunit" ? Because when I elimanate the red I can see a 'light bluish' ...
0
votes
1answer
75 views

My resize.c passes tests of check50 ony when the resizing factor is either 1 or a multiple of 4

int no=atoi(argv[1]); //iterate over infile's scanline for(int i=0,bHeight=abs(bi.biHeight);i<biHeight;i++) { int num=no; //iterate over each pixel in a scanline for(int j=0;j<bi....
0
votes
2answers
209 views

I don't understand the concept of recover

I dont understand the concept of recover. I tried watching the walkthroughs and it really doesn't make sense. Are you supposed to make your own jpegs or does cs50 provide it. Can someone explain. ...
1
vote
1answer
942 views

pset4 recover works correctly but fails check50

Morning, I have just finished pset4 recover. The program works correctly and I can see all 16 jpgs and they are labeled correctly however check50 is failing:- jharvard@appliance (~/Dropbox/CS50/...
0
votes
2answers
412 views

pset4 resize.c appears to give same ouputs as staff solution but won't pass check50 or diff

I have been working on pset4 resize and it appears (to me at least) to work. I tested it by running smiley through the staff's implementation of resize with n = 4 and comparing results with my own ...
0
votes
1answer
105 views

Pset4 recover problems detecting jpg data

So right now, my code can open the compact flash card and look for jpg headers byte by byte. It tells me that it has found 16 jpg files (which is what I had anticipated). However, my concern is ...
0
votes
1answer
1k views

error: invalid operands to binary expression ('int *' and 'LONG' (aka 'int'))

I'm pretty sure I'm using pointers incorrectly but I don't fully understand why using them in this way is wrong. The compiler seems to throwing out an error on the line (near the bottom of the code) ...
0
votes
1answer
73 views

code on infinte loop: start of a jpg UPDATE

I've some issues with my code, it compiles but it gets stuck in an infinite loop. I've run gdb and apparently it never finds the start of a jpg. here is a snippet:(UPDATE here is the rest of the ...
0
votes
1answer
198 views

PSET4. Resize. I can't enlarge the picture in height

[mod removed code] The picture resizes perfectly in Width. But i just can't get it in height. I added that fseek function, but it doesn't really seem to work. The image just gets weird, but still ...
1
vote
0answers
999 views

pset4 how to enhance the colors in the background

How do I enhance the colors in the background. I've added white colors to the image, making it much more visible, but not sure whodunit. I am trying to enhance the sky blue in the image so that I can ...
0
votes
1answer
167 views

recover onlys recovers 1 image out of 16

my code for recover only successfully recovers 1 image. It seems to me that the loop only executes once. I don't know what I am doing wrong. So below is my code and I am wondering if you guys can help ...
0
votes
3answers
2k views

Need help, on pset4, whodunit. I am trying to change all instances of red to white

Need help, on pset4, whodunit. I am trying to change all instances of red to white, instead of black. When I changed all instances of red to black, I was able to see a bit of the image beneath it , ...
0
votes
1answer
471 views

pset4 recover segfault: no such file/directory

My code seems to have trouble making the .jpg files in which to place the blocks of data. #include <stdio.h> #include <stdlib.h> #include <stdint.h> uint8_t buffer[512]; uint8_t ...
2
votes
1answer
214 views

why does my program recover only 3 JPEGs correctly?

When I run my recover program, it makes 16 JPG images. 3 of these JPG images (specifically, the 3rd, 8th, and 9th images) are perfect. The others, however, display question marks. When I try to open ...
0
votes
0answers
416 views

recover.c failing to fill buffer array with 512 bytes?

I am working on pset4 recover.c and I am stuck on trying to fill a buffer array with 1 block or 512 bytes from card.raw. The problem I am having is that fread successfully fills 4 bytes of data ...
0
votes
1answer
110 views

Resize not working (writes RGBTRIPLE too many times)

In resize.c, the image created in my resized image is a tiny image with a black blotch in the middle, regardless of whether I use small.bmp or smiley.bmp as input. When I run xxd, the header in the ...
1
vote
1answer
2k views

resize cs50. I am updating headers correctly?

I am struggling with this program. I cannot even check the headers with peek (I am receiving the message "could not recognize sample.bmp"). I am sure my program has several issues, but I would like to ...
0
votes
1answer
88 views

Resize problem in pset4

I find that a bitmap which is been provided has following properties. {biSize = 40, biWidth = 3, biHeight = -3, biPlanes = 1, biBitCount = 24, biCompression = 0, biSizeImage = 36, biXPelsPerMeter = ...
0
votes
1answer
142 views

recover Only finding 8 images

Someone please help, my recover program will only find 8 images it's driving me crazy, here is my code. while(fread(block, SIZE, 1, file) > 0) { if(img) { fclose(img); } //...
0
votes
0answers
124 views

Problem in recover in pset4

I have done my recover program and I get the 16 jpg images. They are well named and I can see them so the program is working correctly but when I check the program I get an error in the set recovers ...
0
votes
1answer
187 views

Not writing to the jpegs

I'm currently struggling through recover.c, i've managed to get everything working apart from writing the actual jpegs and opens them in their individual files it just doesn't write anything to them. ...
0
votes
1answer
361 views

pset4 resize vertical sizing problems. Need help

I am attempting pset4 resize right now and I am running into a bit of problems on the part where you have to vertically size the image by a factor of n. So, my logic is to declear a dynamically ...
0
votes
2answers
497 views

Resize.c creates bitmaps with only first few pixels copied

My implementation creates the headers properly (verified with xxd), so I know it's somewhere in this loop that I'm missing something. I've been trying all sorts of variations of this code, but cannot ...
0
votes
1answer
2k views

recover pset4 Why "error interpreting JPEG image: Improper call to JPEG library in state 201 (or 200)"

(int j is just for checking) typedef uint8_t BYTE; typedef struct { BYTE buff[512]; }__attribute__((__packed__)) BUFFER; int main(int argc, char* argv[]) { // open input file FILE* infile = ...
0
votes
1answer
127 views

Why is diff showing two identical bmps different?

In the whodunit assignment, when I used the copy.c given in the pset4.zip on smiley.bmp and executed the diff check, there was no message shown. However, when I used the copy.c and diff on the clue....
0
votes
1answer
132 views

My resize.c program is getting partial success

After several failed attempts to fix my code I am still getting errors while trying check50. Below is the code. Help please!
1
vote
1answer
547 views

why does check50 claim that 015.jpg wasn't recovered correctly? [duplicate]

This is my sandbox link: https://sandbox.cs50.net/checks/0d0024b391314b4597be136798827f98 while(feof(fp)==0) { // recover images } Edit: I'm opening only one file at time and I'm closing the ...
0
votes
1answer
533 views

pset4 - image resizes correctly, but check50 detects some faults

I've been able to resize images correctly (I checked several sizes and images and apparently everything works), but check50 complains saying that it doesn't resize correctly. I think the problem is in ...
0
votes
1answer
107 views

Problem in grading for pset4

I've successfully completed the pset4 and submitted the code. I've checked the correctness of my code with check50 and I have: :) recover.c exists :) recover.c compiles :) recovers 000.jpg correctly :...
0
votes
1answer
550 views

what is wrong with my vertical-resizing algorithm?

It looks like my horizontal resizing is working, but the vertical isn't. I can't figure out where I'm going wrong. I've been testing as described in the pset. ./resize 4 small.bmp student.bmp ~cs50/...
0
votes
2answers
144 views

recover function causes segmentation fault

I've finished writing the recover function and made it to compile successfully. However, it gives out a segmentation fault every time I try to run it. I ran valgrind and the error was in the first if ...
0
votes
1answer
756 views

what is the problem with my resize?

I'm having trouble making getting resize to work correctly even though I spent so much on it. I feel it's somewhere in the for loop where I'm storing the RGBTRIPLE in current_row. Here's my code: ...
0
votes
0answers
124 views

pset4 recover can't find more than one jpg

I'm doing pset4 recover program. I've written following code to read 512 bytes of data at once and detect the start of any jpg image BYTE buffer[512]; while((fread(buffer, 512 * sizeof(BYTE), 1, ...
0
votes
1answer
100 views

Check50 reports all tests after not resizing 1X1 bitmap with n = 1 fail despite header and image pixels being correct

Code: /** * copy.c * * Computer Science 50 * Problem Set 4 * * Copies a BMP piece by piece, just because. */ #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(...
0
votes
1answer
368 views

check50 error on resize.c pset4

My program for resize.c is able to resize the bmp's provided with the pset4, for example small.bmp, smiley.bmp but after running the command check50 2014.fall.pset4.resize bmp.h resize.c on terminal ...
0
votes
1answer
219 views

Bitmap file size

which field in BITMAPFILEHEADER & BITMAPINFOHEADER represents the size of the image? whether it is bfSize of BITMAPFILEHEADER or biSizeImage of BITMAPINFOHEADER as in the specification at https://...
0
votes
2answers
262 views

Why does my recover.c only recover 13 images?

When I run my program, only images 000.jpg through 012.jpg are recovered, and I can't figure out why. I've gone through the code over and over, checked everything, and I've added comments for ...
2
votes
1answer
1k views

pset4 : How does the xxd command work?

Specifically, could someone explain what the flags used with the commands are? In the pset4 specs at one point it is mentioned that they use a different value for -c depending upon the number of ...
0
votes
1answer
82 views

Resize only works when n % 4 = 0, when n = 1 or when i resize a 2x2-pixel BMP and n =2

I don't know exactly where is the problem. Resize gives me a bunch of different colors when n % 4 !=0. Can you guys help me understand what I'm doing wrong? // iterate over infile's scanlines { //...
0
votes
1answer
1k views

whodunit section

I've just started doing pset4. I'm stuck in whodunit section itself, I've no idea about the questions in whodunit section. After opening the file, there are list of todo's corresponding to each number ...
0
votes
1answer
96 views

Why is biSizeImage a random number?

I found this anomaly when running peek, then confirmed with gdb that bi.biSizeImage is getting set to 4294966864 when it should be 432.
0
votes
1answer
518 views

biWidth x biHeight x bytes per pixel != biSizeImage

The data is from clue.gmb run by copy Why is biSizeImage and bfSize 2 bytes larger than expected? Is this an inherent property of bitmap images that I'm not aware of, or is something else going on? ...
0
votes
1answer
94 views

fread not updating the values in my struct in recover pset4

I created a struct typedef struct { BYTE buffer[512]; } __attribute__((__packed__)) BUFFER; then I try reading card.raw and writing to a new file in a while loop fread(&photo, sizeof(...