I'm working on recover.c.

It seems like a tidy solution to eliminate fseek calls would be to create a struct like the following:

typedef struct
    BYTE first;
    BYTE second;
    BYTE third;
    BYTE fourth;
    508*sizeof(BYTE) remaining;

That way I could write data to the buffer, then immediately check parts of the buffer without modifying the read head with fseek.

But I don't know how to actually accomplish the 5th element of that structure. Is it possible to create an element of 508 bytes to put in there?

(Apparently I can also just malloc 512 bytes, then use sizeof(BYTE) to check, so I'll be looking into that solution while I await an answer here!)

1 Answer 1


There are any number of ways to implement what you want. The most obvious would be to declare a struct element that is a 508 byte array. This assumes that you really want to implement a struct.

But wouldn't it be far simpler to implement an array of 512 bytes instead of a struct?

            BYTE buffer[512];

You would be able to check the first 4 bytes individually for the signature, while reading and writing the entire buffer as a single step.

You must log in to answer this question.

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