I've been struggling with this for a while. After reading other posters questions and reading the responses I've managed to come up with code that compiles and works correctly only if the value of 'n' entered by the user is a multiple of 4.

The area I am least confident in my code is the usage of fseek. Another poster on the site had used SEEK_SET rather than SEEK_CUR and I borrowed that for my code. I believe I understand how and why it works, but I didn't come up with it myself and I wonder if this could be contributing to my problem somehow?

As for the problem, I think it's a padding issue but I've gone over my code and all of the padding to outfile seems to be within the correct loops. Can anyone point me in the right direction?

My code can be found here


As I understand it, the bit you're asking about is where you put in the offset in bytes. So something like: fseek(inptr, 512, SEEK_CUR) This will move the cursor forward 512 bytes from the current position.

To move the cursor backwards would require a negative number (eg -512).

You can also fill the middle section with an equation if you don't know the exact integer value required (or a variable that refers to an integer or formula, such as "InPadding," in the supplied fseek which occurs towards the end).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .