I was looking at this piece of code and I'm not sure what the addition means if "a" is an array.
int main(int argc, char* argv[]){
int a[] = {1, 3, 5, 7, 9};
function(1, a+2);
return 0;}
Assume the function is already created.
In an expression (except when used with sizeof or &), an array name is a pointer to the first element in the array. So a+2
is "pointer arithmetic" on that pointer, and results in a pointer to the element at offset 2. It is equivalent to &a[2]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With