// 得到数组的最后一个数 - 使用指向数组的指针来完成
#include <stdio.h>
int main()
{
const int MAXN = 8;
int a[MAXN] = {1, 2, 4, 8, 16, 32, 64, 128};
int *p = (int*)(&a + 1); //&a 是一个指针,指向大小为4的数组 int(*)[MAXN]
printf("%d\n", *(p - 1)); //为128
return 0;
}
—————————————————————————————————
本文原创自Slience的csdn技术博客。
本博客所有原创文章请以链接形式注明出处。
欢迎关注本技术博客,本博客的文章会不定期更新。
大多数人想要改造这个世界,但却罕有人想改造自己。
世上没有绝望的处境,只有对处境绝望的人。
————By slience
—————————————————————————————————