Question: int a[10]; q Which of the following can not represent a[1] addresses?
A, a+sizeof (int)
B, &a[0] + 1
C, (int*) &a+1
D, (int*) ((char*) &a+sizeof (int))
#include <stdio.h>int main () {int a[10] = {1,2,3,4,5,6,7,8,9,0};p rintf ("******* output Address *******\n");p rintf ("a[0] =%d\n ", a);p rintf (" a+sizeof (int) =%d\n ", a+sizeof (int)); A+1 for address plus 4, here is equivalent to add the address of printf ("&a[0" + 1 =%d\n ", &a[0] + 1); This plus 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)));// This first turns the address into a char-type pointer, and then +4 is added by the char type length, and finally to the integer printf ("\ n"); printf ("******* output Value *********\n");p rintf ("a[0] =%d\n", *a);p rintf ("a+sizeof (int) = %d\n ", * (a+sizeof (int)));p rintf (" &a[0] + 1 =%d\n ", * (&a[0] + 1)); printf ("(int*) &a+1 =%d\n", * ((int*) &a+1));p rintf ("(int*) ((char*) &a+sizeof (int)) =%d\n", * (( int*) ((char*) &a+sizeof (int))); return 0;}
Output:
Results:
The answer is a.
C language Pen question selection 2---int a[10]; q Which of the following can not represent a[1] addresses?