/* * Problem: Given an array A, and the value &A[x] find x. */ #include #define TESTVALUE 5 int main(void) { int x=TESTVALUE; int A[]={0,1,2,3,4,5,6,7,8,9}; int one_element=sizeof(A[0]); printf("one_element=%d\n", one_element); int finding_x=( (unsigned long)(&A[x]) - (unsigned long)(&A[0]) )/ one_element ; printf("Address &A[x]=%p\n", &A[x] ); printf("Address &A[0]=%p\n", &A[0] ); printf("finding_x=%d\n", finding_x); return 0; }