Answer the question
In order to leave comments, you need to log in
How is structure packing going on here?
I enter 1 record from the keyboard, I pack it as a structure into a binary file. I don't understand how alignment works in this case.
The first 2 fields of the record are strings (static), the maximum length (set by me) of the first field is 30 characters + 1 under '\0', the second has 15 similarly. 3 and 4 int fields. I pack the structure, it packs the first field into 31 bytes, and then the second field immediately begins. The first is clearly not aligned, it turns out that if, for example, as I understand it, 3 and 4 fields are aligned by 4, then the first should have aligned to 32.
How is the structure packed here?
I enter the following entry: name producer 1 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question