Hi,
I have a question to that struct:
I thought sizeof(Buchung) would be 124 Bytes 8 + 11 + 4 + 101 but it is 128. Why?Code:typedef struct b { double amount; char date[11]; struct buchung *next; char description[101]; } B;
Thanks,
keeper
Hi,
I have a question to that struct:
I thought sizeof(Buchung) would be 124 Bytes 8 + 11 + 4 + 101 but it is 128. Why?Code:typedef struct b { double amount; char date[11]; struct buchung *next; char description[101]; } B;
Thanks,
keeper
The compiler may add extra bytes between members in a structure, so that some member (probably the *next pointer here) will be aligned on a certain boundary in memory. Having things aligned on 4,8,etc byte boundaries can boost performance, or is sometimes just required. (The same rules apply to the structure as a whole, so bytes may be added to the end) It's your compiler taking care of the detail work so you don't have to.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
The layout is most likely 8 + 11 + 1 byte padding + 4 + 101 + 3 bytes padding. You can use the "offsetof" macro to report the offsets. Think of a struct as an array element itself. If you were to have an array of b structs, they would be required to have the same alignment for every element and have no gaps due to alignment in between elements. Adding the padding where I indicated would meet those requirements, and it matches your results as well.
Todd
Mainframe assembler programmer by trade. C coder when I can.