Skip to main content
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 ...
Cliff B's user avatar
  • 69k
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 ...
Cliff B's user avatar
  • 69k
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 ...
Cliff B's user avatar
  • 69k
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 ...
Cliff B's user avatar
  • 69k
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 ...
MARS's user avatar
  • 5,169
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 ...
Cliff B's user avatar
  • 69k
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(...
Blauelf's user avatar
  • 21k

Only top scored, non community-wiki answers of a minimum length are eligible