Questions tagged [fwrite]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
10 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
35 views

Pset4 Recover. I think that I did well but it doesn't work

I was struggling with this code for three days. someone could help me? What should i fix? Please, if you are so kind, give me a tip, not the solution! I wrote a lots of comments to you can understand ...
0
votes
1answer
45 views

How to write a fread function

Soo i'm a little confuse about the fread/fwrite function ... from what i understood in the videos, you need 4 input for those to work, let's use fread for the exemple fread("place to store the data",...
0
votes
1answer
43 views

“File size limit exceeded” in Recover - how does file writing work?

I've been quite frustrated by trying to make progress in Recover. When I run my code, I am unable to make even the first JPEG file as the program continues running until the file size is exceeded. I ...
1
vote
2answers
103 views

CS50 PSET4 RECOVER.C SEGMENTATION FAULT PLEASE HELP!

I'm seriously struggling with this assignment and I can't seem to find the problem in my code. I'm supposed to create a program that reads a raw card one block at a time with each block containing ...
0
votes
1answer
26 views

Pset4 Recover, help with writing images correctly

I can create 49 images inside of my loop, but I'm missing something when I write to file. The images are only partly showing. I watched the video three times where Brian explains how to approach this, ...
0
votes
1answer
95 views

For loop vs fwrite for resize

I have managed to finish but i have some queries regarding how fwrite exactly works. If you are new to pset4, the intention of my code is to fwrite the content of triple n times after i have fread ...
0
votes
1answer
45 views

File pointers clarification

i have seen many examples where people uses fwrite with the qty value = 1, and this happens most of the times. However, i would like to have better clarity on the below 2 concepts. I have tried on ...
0
votes
1answer
36 views

fread seems to break my program

I've been spending a lot of time trying to get my head around the fread and fwrite functions. In said (vain) attempts, I made some little changes to the copy.c program that is provided as part of ...
0
votes
1answer
201 views

How to keep track of cursor in fread/fwrite etc

after two or more weeks I have finished recover problem set - the longest issue was with the cursor and debugging. I less than more know how to use debug50 but if somebody could tell me how can I ...
0
votes
1answer
135 views

PSET4 Recover images not showing correctly

Here is updated code with answer. #include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(int argc, char *argv[]){ if (argc != 2){ ...
0
votes
1answer
41 views

PSet5 Speller - program can't identify the Misspelled words

can someone have look at my PSET5 - speller code. I have tried to fix it for five hours, and I don't seem to go anywhere. Thanks in advance! typedef struct node{ char word[LENGTH+1]; struct ...
0
votes
1answer
76 views

Pset4 resize(less) output issue, using third argument of fwrite

In Pset4 resize(less), I try to resize the width of image by using fwrite. gain is integer I use for resize factor. Originally I was doing like this. I put gain to the third argument of fwrite, and ...
0
votes
1answer
43 views

pset4 resize - can't write all the characters from infile to outfile

everyone! I really need your help. I'm working on pset4 and trying to understand the logic of resize problem. I have two files:testinp.txt and testout.txt. Inside of testinp.txt I have: ...
1
vote
1answer
424 views

Pset4 Resize.c Array Overstepping

I have been stuck on resize for a while. I am currently struggling on the vertical portion of resize. I am using the "rewrite" method as explained in the problem spec. My program does resize an image ...
0
votes
1answer
169 views

Code Seems Correct but Output is garbage

Further to the question I posed yesterday, in which I couldn't compile as my declaration of buffer was incorrect. This has now been resolved as you can see in my code below, and the code will in fact ...
0
votes
1answer
119 views

Recover Pset4 - Getting 24 images

First time on the site, I've been trying to do this pset by myself but as I write this thread, I have already spent easily more than 10 hours only in this code. I have reviewed it thoroughly once and ...
0
votes
1answer
155 views

pset4: File operations using fwrite(arguments)

I'm writing the code for resizing the image . I have an issue while using the fwrite function. fwrite( const void *buffer, size_t size, size_t count, FILE *stream ); From what I understand the ...
0
votes
1answer
48 views

Query on fread (or fwrite)

Is there any difference between the below lines of code? fread(&buf, sizeof(int), 10,infile); and for (int i = 0, i < 10, i++) { fread(&buf, sizeof(int), 1,infile); } If so (or not ...
0
votes
1answer
22 views

fundamental issue with fwrite

I'm doing some simple testing with fopen and fwrite. I'm doing this just to make sure I understand how they work. I wrote a simple program to create a new file and write one word to it. I'm ...