& Quot; trap & quot;, counts trap

Source: Internet
Author: User

The "trap" that should be paid attention to when calculating the array name and address is counted as trap.

"Trap" should be noted when calculating the array name and address"




View the Code directly:

# Include <stdio. h> int main () {int array [5]; printf ("array: % p \ n", array); printf ("array + 2: % p \ n ", array + 2); printf ("& array + 2: % p \ n", & array + 2); return 0 ;}


Program output:


Array name as the pointer array is not easy to talk about, but to get the address & array of the array name, the result is a pointer to the entire array, note that this is not just a pointer to the first element, although the two (array and & array) are consistent in values.

The addition and subtraction of the & array pointer is based on the entire array size, that is, the size of the array is 5, then & array + 2

Is to double the size of the entire array, that is, 0x7fff8423890 + 0x14*2;









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.