Questions tagged [fseek]
The fseek tag has no usage guidance.
35
questions
0
votes
0
answers
53
views
Where is padding of a scan-line situated? Are metadata of a BMP file skipped when pointing to the file?
I'm working on a practice problem (bottomup). In that program (see below) is a code line:
fseek(inptr, padding, SEEK-CUR) this code line is supposed to skip over padding.
WHAT I UNDERSTAND, I think:
...
0
votes
1
answer
46
views
PSet4 / Resize / Less: When to put the pointer back to the beginning?
I'm struggling with when to put the pointer back to the beginning.
Every time I want to copy the same scanline vertically, I know I need to move the pointer on the input file from the end of the ...
0
votes
1
answer
333
views
Understanding padding and fseek()
I have a simple doubt that, can padding be put for all of the scan-lines at once?
What I mean to say is, that suppose, I have bi.biHeight == 10
then if I Write
for (int k = 0; k < padding; ...
0
votes
1
answer
45
views
Pset4 Resize. Code not working
I have been working on pset4 Resize for a few days now. I have tried researching online for the functions I didn't understand and been going through the lecture and walkthroughs and the notes but I'm ...
0
votes
1
answer
152
views
Pset4 resize less comfortable, problems with fseek
I'm struggling a bit with resize. I think my headers work correctly as I do get a correct size output, but after the first horizontal line everything goes wack.
My guess is that the fault lies in how ...
0
votes
1
answer
81
views
CS50 Pset4 Resize - Vertical Sizing
I have no problems with the horizontal resizing but can't identify what is the problem in my code with the vertical resizing. Any help would be much appreciated.
/**
* Copies a BMP piece by piece, ...
0
votes
1
answer
213
views
Pset 4 Resize fseek()?
I'm looking over my resize code rn, but have been stuck for a while now, was wondering if anyone could point me in the right direction.
The resized images have colors beside green, which I would ...
0
votes
1
answer
104
views
fseek doesent do what i expected
so what i am trying to do is to make fseek return to a new line as long as its smaller than factor i need to resize with. so fseek retruns to a start of line as long as its need to print those ...
0
votes
1
answer
59
views
Vertical resizing with fseeks()
I am having a problem with fseek() to move the cursor back for copying line
My code is below:
int old_padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
bi.biWidth *= n;
bi.biHeight *...
1
vote
1
answer
203
views
pset 4: resize adding in black pixels
Whenever I run my program on small.bmp passing in:
$ ./resize 4 small.bmp larger.bmp
I end up with this:
It seems like the size is correct, but it's adding a black pixel after each line in the ...
0
votes
1
answer
898
views
How to debug fseek not working as intended
I am pretty certain that my problem in this problem is my fseek in my vertical resizing for loop. Basically my idea is to print out horizontally resized code once per scan line always, then depending ...
1
vote
1
answer
586
views
CS50 pset4 recover: buffer type and fseek questions
I have figured out a solution to recover, but my first attempt did not work. I'd like to understand a couple of things from my original attempt so I don't repeat the same errors in future code.
...
1
vote
1
answer
103
views
Pset 4 Resize makes a very colorful picture (not green!)--padding problem?
Well, it looks like I'm not the only one having issues with padding (I suspect that's my problem).
Specifically, if I test my version of resize with an enlargement factor of 2 (using small.bmp as ...
0
votes
1
answer
284
views
PSET4 'resize' Padding is wrong
I'm stocked in resize
My main problem is when it comes to enlarge a file that has some padding, i cannot enlarge it
But when I run my program trying to enlarge a file with no initial padding, it runs ...
0
votes
1
answer
543
views
pset6 load - why does fseek(file, 0, SEEK_END); size = ftell(file); not work?
after some struggles I just finished pset6.
In particular my load function caused quite some pain. I thought I'd be spart and instead of reading the file in chunks of 512 bytes and doing a lot of ...
0
votes
1
answer
244
views
How to use fseek along side arrays? Pset4 recover
I'm re-wrote this code and did not get any output or error. Tried valgrind and nothing was leaked.
I suspect it's either:
1) my fseek is not moving my cursor in inpt 'card.raw'
2) and/or.. because ...
1
vote
1
answer
118
views
pset4/resize. problem with resize code and i don't know what to do
I am trying to solve resize but I am facing problems and I don't know what to do. I don't even know is the problem with my info update or with fseek.
I feel that there is something I miss or don't ...
0
votes
1
answer
60
views
pset6 server2 load() fseek() return -1 [SOLVED]
I'm almost done with this one. However I have one more bug that I can't resolve.
fseek is returning -1 only for some cases.
errno's value is 29 after ftell, if that helps.
check50 says:
$ check50 ...
1
vote
1
answer
1k
views
what's the purpose of fseek in PSET4?
what is the purpose of even using Fseek() in pset 4 anyhow? I must be missing something
Say we're looking at the original copy.c function.
Basically, this is what I understand what's happening:
...
0
votes
1
answer
240
views
Pset4 odd behavior
I can't really figure out while my code end up making a weird version for the resize pset. It compiles and run but the image is not quite what it's suppose to be. Thanks for your support!
[EDIT: ...
0
votes
1
answer
1k
views
pset4 runtime error: unsigned integer overflow
my resize programm in pset4 has an error:
resize.c:125:38: runtime error: unsigned integer overflow: 18446744073709551613 * 3 cannot be represented in type 'unsigned long'
Here is my code:
/**
* ...
0
votes
1
answer
389
views
pset4 resize fseek() - non proper work
I have similar question as there was asked, but can't find answer.
Here is my code:
/**
* copy.c
*
* Computer Science 50
* Problem Set 4
*
* Copies a BMP piece by piece, just because.
*/
#include &...
0
votes
1
answer
149
views
pset4 resize problem with padding
I've been trying with this problem for more than a week now .. I guess I've figured out fseek() .. and the code works fine with files without padding, but it doesn't with ones that have padding ... so ...
1
vote
1
answer
168
views
Pset4 resize - half working, padding issue?
So I am really having a hard time with pset4 resize. After 2 days I finally managed to have it resize the smiley correctly, but the small image is still incorrectly displayed (black bg, with glitchy ...
1
vote
1
answer
319
views
pset4 Resize - Trouble Understanding Padding
I'm having a hard time understanding pset4's resize. Although I understand the theory, it's difficult for me to turn it into a program.
I do understand that the scan line's total width must be a ...
0
votes
1
answer
47
views
pset4 vert resize doesn't work with 1x1 px image
can someone point me in the right direction, when I resize small.bmp it works in all instances but check50 doesn't like it when it resizes smaller bmp's. I think maybe it has something to do with my ...
1
vote
1
answer
3k
views
Help with fseek and fgets
I am trying to fully grasp how these functions work.
From the Reference50 website:
fseek
FILE* out = fopen("out.txt", "w+");
fputs("Team Bowden Fever!", out);
char buffer[50];
fseek(out, 0, ...
0
votes
1
answer
202
views
Please explain why copy.c skips over padding and how it then adds it back?
This is a two part question:
1) Why does copy.c have to skip over padding?
2) If it already skipped over the padding, why is it adding it back? Wouldn't this make extra padding?
I have been reading a ...
2
votes
1
answer
1k
views
pset4 resize - fseek help (I think)
I'm on the verge of giving up. I've been stuck on this problem for weeks. I managed the headers, and I think I set up the loops right to write the pixels correctly. I just can't wrap my head around ...
1
vote
2
answers
132
views
Yet again, problem with padding
I am having a problem with my code, and I think it has to do with the use of fseek. I have read a lot of the articles on the cs50 Stack Exchange, and tweaked my code a lot, but my problem still ...
4
votes
1
answer
596
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
1
answer
110
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
1
answer
517
views
resize pset 4 confused on number of things
I think I have the headers correct except for the new bf.Size not to sure on that one. I am having real problems with resizing the bitmap and I can't figure out what it is, any hints or pointers in ...
1
vote
1
answer
553
views
fseek in pset4(whodunit)
everyone, this is a segment of the code from pset4(whodunit) copy.c, and I'm wondering why the function fseek is needed. Given that padding cannot be read by fread, why not just simply use fputc to ...
3
votes
1
answer
1k
views
pset 5 resize vertically - use of fseek
I am struggling with the vertical resizing using the recopy approach.
I read a pseudocode in an answer to another question in this forum and am trying to code it. I feel I am near but something is not ...