Writing to a binary file.
Posted on 2006-07-09
Hello experts - I am having problems with keeping track of the positioning of buffer2!
This is what I am trying to do...
I am trying to write to a binary file. I have created a struct (size 12 bytes).
genData(teststruct &test1, unsigned char *buffer1, int maxBytes)
//Allocate memory for buffer2
unsigned char buffer2* = (unsigned char*) malloc (maxBytes);
Copy struct into buffer2
Then read the first 48 bytes from buffer1 and append it to buffer2
Append arbitrary 1 byte value to buffer2
Append same struct to buffer2
Read in the next 48 bytes from buffer1 and append it to buffer2
Append 1 byte value to buffer2...
etc...until all bytes have been used from buffer1.
Once all bytes have been used - write entire buffer2 to file.