arr[index] is equivalent to (arr + index), which by the commutative property of addition is equivalent to (index + arr) = index[arr].
Mind = blown
1–7 of 7 posts
arr[index] is equivalent to (arr + index), which by the commutative property of addition is equivalent to (index + arr) = index[arr].
Mind = blown
arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr
It's not the same as (index + arr). arr is a pointer to the beginning address of a series of particular "types". These types have a specific size in memory. Index increments the pointer by (n * size_of(type)). arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr
*(index + arr)
which is correct.C pointer arithmetic already accounts for object sizes.
And it's sizeof, not size_of. And
arr + x
is completely different from x + *arr
And it's a series of "values".It's not the same as (index + arr). arr is a pointer to the beginning address of a series of particular "types". These types have a specific size in memory. Index increments the pointer by (n * size_of(type)). arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr
He said it's the same as *(index + arr) which is correct. C pointer arithmetic already accounts for object sizes. And it's sizeof, not size_of. And arr + x is completely different from x + *arr And it's a series of "values".
It's not the same as (index + arr). arr is a pointer to the beginning address of a series of particular "types". These types have a specific size in memory. Index increments the pointer by (n * size_of(type)). arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr
He said it's the same as *(index + arr) which is correct. C pointer arithmetic already accounts for object sizes. And it's sizeof, not size_of. And arr + x is completely different from x + *arr And it's a series of "values".
It's not the same as (index + arr). arr is a pointer to the beginning address of a series of particular "types". These types have a specific size in memory. Index increments the pointer by (n * size_of(type)). arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr
It's not the same as (index + arr). arr is a pointer to the beginning address of a series of particular "types". These types have a specific size in memory. Index increments the pointer by (n * size_of(type)). arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr