Struct and pointer

Source: Internet
Author: User

If we use [0x9999] to mark the memory address, * [0x9999] indicates the value stored in the address memory.

Variable
Int;
A * [0x9999] 1
& A [0x9999]

Pointer
Int *;
A * [0x8888] [0x9999]
* A * (* [0x8888]) * [0x9999] 1
& A [0x8888]

Struct variable
Struct mystruct
{
Int A; [0x9991]
Int B; [0x9992]
Int C; [0x9993]
} S;

S * [0x9991] 1
& S [0x9991]
S. A * [0x9991] 1
& S. A [0x9991]

Struct pointer variable
Struct mystruct
{
Int A; [0x9999]
Int B; [0x999a]
Int C; [0x999b]
};

Struct mystruct * s;
S * [0x8888] [0x9999]
* S * (* [0x8888]) * [0x9999] 1
& S [0x8888]

S-> A * (* [0x8888]) * [0x9999] 1
& S-> A [0x9999]
* S-> anone

Array (strange)
Int A [];
& A [0x9999]
A [0x9999]
* A * [0x9999] 1

A [0] * [0x9999] 1
& A [0] [0x9999]


Struct array (strange)
Struct mystruct
{
Int A; [0x9999]
Int B; [0x999a]
Int C; [0x999b]
};

Struct mystruct s [];
S [0]. a x [0x9999] 1
S [0] X [0x9999] 1
& S [0] [0x9999]

S [0x9999]
* S x [0x9999] 1
& S [0x9999]

 

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.