For a lab we are required to read in from binary files using low level io (open/lseek/close not fopen/fseek/fclose) and manipulate the data. My question is how do I read or write structs using these methods.
The struct is as follows
typedef struct Entry {
char title[33];
char artist[17];
int val;
int cost;
} Entry_T;
I originally planned on creating a buffer of sizeof(Entry_T)
and read the struct simply, but I don't think that's possible using low level I/O. Am I supposed to create 4 buffers and fill them sequentially, use one buffer and reallocate it for the right sizes, or is it something else entirely. An example of writing would be helpful as well, but I think I may be able to figure it out after I see a read example.