Created
May 28, 2014 08:54
-
-
Save HaiyangXu/db0ce47b85426315080c to your computer and use it in GitHub Desktop.
Test pointer address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cstdio> | |
int main() | |
{ | |
int a[5]={1,2,3,4,5}; | |
printf("sizeof(&a):%d\tsizeof(a)%d\n",sizeof(&a),sizeof(a)); | |
int *ptr=(int *)(&a+1); | |
printf("a=%d,&a=%d,a+1=%d,&a+1=%d\n",a,&a,a+1,&a+1); | |
printf("%d,%d",*(a+1),*(ptr-1)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment