Structure size and binary format
- From: "gamehack" <gamehack@xxxxxxxxx>
- Date: 30 Dec 2005 16:05:03 -0800
Hi all,
I've been wondering when I write a structure like:
struct {
int a;
unsigned int b;
float c;
} mystruct;
And then I'm using this as a record for a binary file. The problem is
that the size of the types is different on different
platforms(win/lin/osx) so if a file was copied on another platform and
attempted to be read then the first say 16 bytes could be regarded as
the integer a but it could have been created on system where integer
was 32 bytes. Is there a portable solution to this? Moreover, I've been
looking for some resource on designing your own binary format and I
couldn't find anything apart from short tutorials how to read binary
files. Are there any good resources?
Thanks a lot
.
- Follow-Ups:
- Re: Structure size and binary format
- From: gamehack
- Re: Structure size and binary format
- From: Malcolm
- Re: Structure size and binary format
- From: Chuck F.
- Re: Structure size and binary format
- From: Mark McIntyre
- Re: Structure size and binary format
- Prev by Date: Re: c.l.c wiki update
- Next by Date: Re: Input-line reverser
- Previous by thread: Printf question.
- Next by thread: Re: Structure size and binary format
- Index(es):
Relevant Pages
|