Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
struct allocation in memory
Is there a way to guarantee that a struct is allocated contiguosly in memory?
Here's my problem: I'm reading the header of a binary file into a relatively big structure (~6Kb).
The first 4 members of the structure are:
If I just look at the addresses of these members I see:
signature : 0x9c085c8
version : 0x9c085cc
mode : 0x9c085d0
len : 0x9c085d4
which are definitely not contiguous.
Is there a way to force the struct to be contiguous so I can read it all at once? Or do I have to read each member separately (that would be quite annoying as the struct has more than 300 members...)?
[italic]How beautiful, if Sorrow had not made sorrow more beautiful than Beauty itself.[/italic]
0 · ·