We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
If I've got a struct like:
struct mystruct { unsigned char first; unsigned short second; };
How would this be stored in the memory if I'm working with a 32Bit ARM7 microcontroller (SAM serie from ATMEL)? for example first=1 and second=2 in decimal.
When I look into the memory window would it looks like 0x20000000 01 00 00 00 0x20000004 10 00 00 00
(so that a char variable needs the same space like a int variable)
0x20000000 01 10 00 00 (or does it looks like that one)? So that the char variable only needs two bytes and the short variable gets the rest of the 8 bytes?
best regards and thanks for your replies Mark
How would this be stored in the memory if [...]?
Ultimately, that's none of your business to know. The program will have two variables that can be accessed individually, or as a group. All else is up to the compiler, and should be kept that way.