[quote name='edd²' timestamp='1307139749' post='4819240']
Ok, but you need to check that you aren't decoding too much or too little data.
Luckily, the person who designed this data file seperated these parts with padding
[/quote]
I'm not sure what difference that makes. All it changes is that you now also need to know where the padding is and how much of it there is.
And do you know the size of each chunk? Have you found C(++) data types that are of an equivalent size? Just making sure you've dotted the 'i's and crossed the 't's...
That's a problem. The size of the chunks can be anything. But, as said, these chunks are surrounded by padding, so it's not too hard to tell what the size of the chunks are at runtime.
[/quote]
How can you tell what's padding? If the file format is documented, it should state the number of bytes for each piece of data in the file.
Here's the code I tried:
unsigned number = 728;
std::vector<unsigned char> v;
v.resize(sizeof(number));
memcpy(&v[0], &number, sizeof(number));
std::FILE *file = std::fopen("test.pwp", "w");
std::fwrite(&v, sizeof(unsigned char), v.size() - 1, file);
[/quote]
What's the -1 for, here?