summaryrefslogtreecommitdiffstats
path: root/negative_array_test.c
blob: 43cd4f4a748b0bc20ba8bbff07b8d5f31ca4bdb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>

int main()
{
	int *a[128];
	int **zero = 0;
	long x = -((long)a / sizeof(int*));
	int **loc = &a[x];
	printf("Location of array: %p\n", &a);
	printf("Location of array divied by size of elements: %ld\n", (long)&a / sizeof(int*));
	printf("Negative index: %ld\n", x);
	printf("Absolute zero: %p\n", zero);
	printf("Our zero: %p\n", loc);
	printf("Inline our zero: %p\n", a[x]);
	printf("Derefed our zero: %p\n", *loc);
	printf("Derefed absolute zero: %p\n", *zero);
	return 0;
}