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
148 views

Recover.c- better implementation?

So the do/while loop is infinite, as I have been told before. Is there a better way to implement this loop? typedef uint8_t BYTE; int main(void) { FILE* file = fopen("card.raw", "r"); if (file == ...
0
votes
1answer
106 views

Recover.c- killed by CS50

I'm not sure what I'm doing wrong here. I wait until the first jpg is reached, then I make new files until the end of the file. This is btw a very difficult assignment!!! check50 says it complies but ...
0
votes
1answer
4k views

segmentation fault in recover

So my problem is that I get a segmentation fault when I run this code and I'm totally unsure why. I don't really understand what is happening in gdb either. This is definitely the most challenging ...
0
votes
1answer
460 views

Padding, pset4, resize. weird xxd output

I have a padding problem in the resize (pset4). I can resize any image that doesnt need padding in their new version, but when it comes to padding it just doesn't work. I checked the headers with peek ...
0
votes
1answer
80 views

pset4: recover.c Why doesn't this work? It always "finds" 0 jpgs (There should be 16)

int tmp; //read from the file to tmp (int) while(fread(&tmp, 1, 1, inptr) == 1){ // if tmp is the first byte of jpg if(tmp == 0xff){ // if it can be read again ...
4
votes
1answer
577 views

what is fseek() exactly doing?

I'm stuck since a while in the 'resize' task. Don't fully get my head around the padding. // read scanline pixel/pixel from infile // write pixels to outfile // skip padding // add padding back ...
0
votes
1answer
125 views

pset4 recover.c signature not written correct

I am using the code below for pset4 recover.c. I can see nothing wrong in this code. The code writes 16 jpgs but none of them is open able. The header of jpg files doesn't seem to have been written ...
0
votes
1answer
100 views

pset4, recover. size of hexadecimal 1 bit?

I don't understand something. In recover, to store the card data, I've used a buffer which is an array of 512 BYTES(i.e. uint8_t). In (almost) every element of the array is stored an hexadecimal ...
0
votes
0answers
678 views

Problem with header data, biSizeImage and bfSize have values of small.bmp

So my code is working fine - images resize exactly as they should (as far as my eye can tell) for images both with and without padding, but my header data is wrong when I compare to staff.bmp. My ...
0
votes
1answer
165 views

Pset4, check50 correct, but grade 0

i am really confused as to why i am getting 0 in my gradebook for recovery. It recovers all the photos and returns check50 with green smiley faces. I don't know what to fix it there is no problems ...
2
votes
1answer
254 views

my pset4 recover grading is 0

my pset4 recover grading is 0. However comment shows all the images recovered successfully. How can I get my grades corrected. Also, all images recovered successfully on my cs50 applaince. check50 ...
0
votes
1answer
134 views

recover.c seg faulting?

My program is seg faulting so impressively that it managed to crash the appliance at one point, and after two days I still can't figure out what's happenning. Help will be massively appreciated at ...
1
vote
1answer
5k views

Pset4, resize, padding

i've been struggling with this for days now. Could someone plz point out what i am doing wrong? It resizes pictures without padding properly, but despite introducing new_padding for resized picture, ...
0
votes
1answer
285 views

pset 4 - recover - Segmentation fault reading into buffer

My program makes one image, then has a segmentation fault. Using GDB, I can see that the segmentation fault happens on the next iteration of the loop after creating the first jpeg. Looking more, I ...
0
votes
1answer
273 views

Pset4 Resize not working

I'm having trouble with pset4's resize.c. It partly works now! But there are these black vertical lines running through the picture. GDB helped. This is my code now. /** * resize.c * * Computer ...
0
votes
1answer
158 views

pset4 resize what is wrong?

Could anyone help? I have been working on resize for days but there must be a bug somewhere because it still does not work. Just an idea, but it is probably fseek(). Any help is appreciated. int main(...
0
votes
1answer
732 views

pset4 - resize.c - Cannot get vertical resizing to work

and thanks for helping me with my problem. I have managed to get horizontal resizing to work within my resizing program, but every time I attempt the next step, I keep failing. Here is the code of the ...
0
votes
1answer
476 views

Naming files in recover.c?

I just wanted to check whether my reasoning with this is correct. We use fopen to start a new file once we start the beginning of a new jpeg, and use the "w" (write) mode, right? And then we need to ...
1
vote
1answer
1k views

Problem with header data in resize.c

My resize.c runs just fine in the terminal, but the newly-created 'resized' image is broken: no image is displayed, and the message 'bogus header data' is shown. I changed the header files like so in ...
0
votes
1answer
250 views

pset4 recover.c seg fault

In my pseudo code this is what this will do(I made FILE* img a prototype also counter = 0 and newcounter is 2 initially ) read the first 512 bytes check if the header is in it if it is say found one. ...
0
votes
1answer
176 views

#pset4, #recover.c

My code recover 12 files. first one is opening, rest are not. What is wrong with the code? #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> ...
0
votes
1answer
56 views

Pset4: recover.c -- quitting early without error

I have written the following code to read the information from the RAW file and try to sort it out into the proper jpeg files. Through gdb, I can see that the file is reading into the buffer fine (...
0
votes
1answer
578 views

#pset4 #recover.c segmentation fault

What is wrong with my code? The error says "segmentation fault core dumped" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> typedef uint8_t ...
0
votes
1answer
472 views

pset4 recover.c. I have no clue on how to start

I get how to solve it. I have the pseudocode in mind on how to solve it. But i cannot understand how do I go about solving it though because I cannot address the most fundamental problem. How do I go ...
0
votes
1answer
202 views

pset4 resize.c doesn't work if n > 1

my resize code doesn't work if n is greater than 1 and i don't understand why, if i printf the values they are right but peek values are wrong. My code is: //resize the image // Get n int n = atoi(...
1
vote
1answer
150 views

Recover.c Nothing Happens!

I run my code which seems right to me but nothing happens! No images appear in my jpeg file!! Please help me I am stuck. Thank you [code hidden to comply to academic honesty] // Checks if file is ...
0
votes
0answers
686 views

Why does my blown up file in resize.c have bogus header data?

Please help resolve this issue.. Thank you so much!! /** * copy.c * * Computer Science 50 * Problem Set 4 * * Copies a BMP piece by piece, just because. */ #include <stdio.h> ...
0
votes
1answer
109 views

Pset4 resize.c outputting giant block of pixels

Firstly I apologize because there are many posts asking similar questions, but I've read over all that I could find, and it appears to me that my logic should be correct. This leads me to believe ...
0
votes
1answer
102 views

resize.c - header processing seems ok, but lines are getting truncated

I've been working on my program to a point where I believe that my headers are being processed okay, they are matching the same output I get from the staff solution. But, when I am running my program ...
0
votes
1answer
153 views

pset4 resize.c enlarge code doesnt work

I cant seem to get my enlarge code to work. I am trying to make it go back and do the pixel n number of times but my code is faulty but I cant figure out why. I have only included my padding and ...
0
votes
1answer
70 views

Segmentation fault error for recover.c

I've been getting segmentation fault errors but i don't know why. I've made sure all our files are opened and closed, made sure nothing "left out" but i still can't get it to work. this seg fault ...
0
votes
2answers
419 views

Developing JPEGS for pset4's recover troubleshooting

I am currently working on cs50's pset4 recover. I have managed to compile the program. However, when run, the images are corrupt and apparently, according to image viewer, are not jpeg files, because ...
0
votes
1answer
46 views

PSet4, recover.c - file returns NULL even if the program is working

I'm on PSet4 right now, implementing recovery.c. It seems to work all right but the only problem I'm having is that when checking if the opened "card.raw" returns NULL, the condition returns true. ...
0
votes
1answer
21 views

Which extension to use?

In pset4's recover, which file extension to use for JPEG images. jpeg or jpg? What's the difference and will it make some difference on output?
0
votes
1answer
105 views

pset 4; Recover - Searching for ffd8ffe0 and storing hexidecimal numbers

I'm working on a portion of the Recover project and was wondering if there is a more elegant solution eluding me. I've noticed that when I come across the first JPEG which starts with ffd8ffe0 gdb ...
0
votes
1answer
121 views

Persistent segmentation fault on pset 4 (recover.c)

I have a segmentation fault that won't go away. Code: /** [mod edit to hide code behind a link] Running gdb, after a few lines, I get an error saying "iofopen.c: No such file or directory." Why is ...
0
votes
1answer
94 views

My code runs, but it creates 15 corrupted images. I've been trying to find the bug(s), but I'm very, very lost. Any ideas on what I'm missing?

#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> int main(void) { uint8_t buffer[512]; FILE* inptr = fopen("card.raw", "r"); if (...
0
votes
1answer
486 views

PSet4 - recover.c generating seg fault

I've been trying to implement recovery algorithm for PSet4. As much as I understand the logic behind it, I'm stuck with the implementation. The problems I'm having: condition if(card == NULL) is ...
3
votes
2answers
1k views

Why abs(bi.biHeight)?

I have written pset4's resize.c and it took me a while to find the bug in my code. All I want to ask is what is the difference between bi.biHeight and abs(bi.biHeight)? With bi.biHeight some cases ...
0
votes
1answer
250 views

Only recovering 8 images in recover.c

I've looked at other forums on the question but it seems every solution varies based on how someone has written their code. So here's mine. Can someone show me the fault in my program. #include <...
0
votes
1answer
218 views

PSET4 Resize Grade states 1x1 doesn't resize correctly when n is 2

Why would my grade show a different result than check50? I uploaded PSET4 and all was well except the grade shows a frown (and 0 points) next to ":( resizes 1x1-pixel BMP to 2x2 correctly when n is 2"...
0
votes
0answers
81 views

Error in recover

I'm not to sure if "Aborted (core dumped)" means the same as "Segmentation fault (core dumped)", but that was the error message I received when I executed the program; however when I ran the program ...
2
votes
2answers
429 views

Pset4: How does fread add properly to the struct?

In Problem Set 4 we're given the copy.c and bmp.h files. On line 47 the fread() function is called with the arguments, &bf, sizeof(BITMAPFILEHEADER), 1, and inptr. I understand what each of these ...
0
votes
1answer
51 views

Getting error messsages in pset4's recover

I am not understanding why I am receiving the error messages undeclared identifiers for initializing unsigned char[512] data or FILE* img? I tried using a uint8_t [512] as well, but received the same ...
0
votes
1answer
640 views

fclose in recover causing segmentation fault

I've "finished" my recover.c, but valgrind says about leaks of memory. It seems like i haven't closed all of my opened files. But I have a problem. If I put fclose function in my loop, to close a file,...
0
votes
2answers
214 views

Compiling whodunit.c

How do we compile whodunit program? Are we supposed to make our own makefile? I tried to do "make whodunit.c" but it gives ms the "make:Nothing to be done for 'whodunit.c'" Thanks!
0
votes
1answer
318 views

I'm lost on how to start pset4's recover.c

I understand the concept of pset4's task, which to uncover a series of JPEG's on a so called "CF" card, but I am clueless on how to get this program going, nonetheless started.... I don't want to look ...
0
votes
1answer
188 views

Need help with "recover"

I can't figure out what's wrong with my code. File names are created successfully but all jpegs just show the corrupt thumbnail. I'm sure it has something to do with finding the start and end of the ...
0
votes
1answer
112 views

Check50 passes in some instanses, despite images and headers identical to staff's?

I compared my headers to the staff's, and they were the same, as well as use the "diff" command and they were the indeed the same. I have read other forums on this site, and I believe the problem lies ...
0
votes
1answer
99 views

Despite having identical Headers to the staff's, image is comes out incorrectly?

// declare updated headers BITMAPFILEHEADER NewBf = bf; BITMAPINFOHEADER NewBi = bi; // update BITMAPINFOHEADER NewBi.biWidth = bi.biWidth * n; NewBi.biHeight = bi.biHeight * n; // determine ...

1
29 30
31
32 33
35