Question 3 on Career Ride suggests that *(x+i) is the same as &x[i]. Can someone please explain whether this is correct?
Question 3 on Career Ride suggests that *(x+i) is the same as &x[i]. Can someone please explain whether this is correct?
That answer is incorrect. Given a pointer variable x and an integer variable i, *(x + i) is the same as x[i] and x + i is the same as &x[i]. It looks like they took half from each side of that for their answer, but they didn't provide any explanation, so we'll never know.
It not the same:
*(x+i): returns the content of the ith element in x array/pointer
&x[i]: returns the address of the ith element in x array/pointer
To be more funny none of the answers on that page is correct. Lovely website :)
a. *(x + n) is same as &x[n] WRONG
b. *&x[n] is same as x + n WRONG
c. *(x + n) is same as x[n] +1 WRONG
d. *(x + n) is same as *x[n] WRONG