C language pen question selection 2 --- int a [10]; which of the following cannot represent the address of a [1?

Source: Internet
Author: User

C language pen question selection 2 --- int a [10]; which of the following cannot represent the address of a [1?

Question: int a [10]; which of the following cannot represent the address of a [1?

A, a + sizeof (int)

B. & a [0] + 1

C, (int *) & a + 1

D, (int *) (char *) & a + sizeof (int ))


# Include
 
  
Int main () {int a [10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; printf ("******** output address ******** \ n"); printf ("a [0] = % d \ n ", a); printf ("a + sizeof (int) = % d \ n", a + sizeof (int); // a + 1 is the address plus 4, this is equivalent to adding 16 printf ("& a [0] + 1 = % d \ n", & a [0] + 1) to the address ); // This addition of 1 is also the address plus 4 printf ("(int *) & a + 1 = % d \ n", (int *) & a + 1 ); // Add 1 is also the address plus 5 printf ("(int *) (char *) & a + sizeof (int) = % d \ n", (int *) (char *) & a + sizeof (int); // here, the address is first converted to a char pointer, and then + 4 is added based on the char length, finally, it points to the integer printf ("\ n"); printf ("***************** \ n "); printf ("a [0] = % d \ n", * a); printf ("a + sizeof (int) = % d \ n ", * (a + sizeof (int); printf ("& a [0] + 1 = % d \ n", * (& a [0] + 1 )); printf ("(int *) & a + 1 = % d \ n", * (int *) & a + 1); printf ("(int *) (char *) & a + sizeof (int) = % d \ n ", * (int *) (char *) & a + sizeof (int); return 0 ;}
 

Output:


Result:

The answer is.

Related Article

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.