Static storage zone storage address from low to high

Source: Internet
Author: User

Static storage zone storage address from low to high

Union UX

{
Int;
Char ch [2];
} X; // The space is 4 of the int, that is, 00000000 00000000 00000000 00000000. This variable is a global variable and has a static storage area.

Int main ()
{
X. ch [0] = 1; // first save low position 00000000 00000000 00000000
X. ch [1] = 5; // in turn to the high-bit 00000000 00000000 00000101, that is, 00000001

Cout <X. A <Endl; // 1281

X. A = 769; // 00000000 00000000 00000011 00000001
Cout <"x. ch [0] = "<(INT) X. ch [0] <"\ NX. ch [1] = "<(INT) X. ch [1] <Endl; // the low position is 1, followed by 3, followed by 0, 0

Return 0;

}

Note: Stack is stored from high to low

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.