10
votes
Accepted
pset4: resize.c - why is biWidth written as bi.biWidth
Welcome to the wonderful world of structures! ;-)
A structure, or a struct, is a collection of individual vars combined into a group. The group has a variable name, and each element in the struct has ...
4
votes
Accepted
How do the headers in copy.c update on pset4?
In your example, bf and bi are pointers to two different structures that hold several variables each. These commands will actually write out the indicated full header structures out to the files. Let'...
3
votes
Accepted
what's the purpose of fseek in PSET4?
First the padding. Keep in mind that the input file and the output file may or may not require the same amount of padding. In item 5, you don't examine the padding in the input file, you skip over it ...
2
votes
Accepted
Pset 4 - Help understanding structs in copy.c
Yes, you have it right. When a struct is declared, the type, size and location of each var in the struct is remembered. The order of those vars is also important. Physically, each var in the struct is ...
1
vote
Accepted
pset4 how does incrementing j help to iterate over pixels?
Both the i and j counters are used to count passes through the loops. They aren't actually used inside the loops, but they don't need to be.
Let's start with the inner loop. biWidth is the number of ...
1
vote
pset4 whodunit can't understand the infile pointer
The notation of the code makes it clear, argv [1] and argv [2] are variables of the pointer type, as the char * infile statement suggests, I do not remember if the theme of the pointers has already ...
1
vote
Accepted
Pset 4- Copy.c- Padding question
Remember that this is copy.c. It's purpose is to merely copy the file, not alter it. The headers are copied, not altered, so it isn't a problem. The value of padding isn't needed to merely copy the ...
1
vote
determine padding for scanlines in copy.c
It's not needed for a padding of 1, 2, or 3 bytes.
But imagine what happened if bi.biWidth were a multiple of 4.
bi.biWidth * sizeof(RGBTRIPLE) would be a multiple of 4.
(bi.biWidth * sizeof(...
1
vote
Dose anyone know where memory allocated in resize.c and copy.c?
Unless you've been doing any mallocs (which aren't really needed), my guess is it's because you're not closing all files that you've opened.
1
vote
How are file data stored in an int buffer?
I really don't understand it very well myself but i am going to try explain it.
It is all related to the way this values are stored in the memory, RAM, hard drives, ..., integers, decimal numbers, ...
1
vote
Accepted
How are file data stored in an int buffer?
It can't be bfType = 0x424d because that is a completely different
number.
Yes, it would surely be a different value if it was interpreted as a whole and compared it with each of the 0x42 and 0x4d ...
Only top scored, non community-wiki answers of a minimum length are eligible