how “Address of” (&) an array / address of being ignored be gcc?

Questions
I am a teaching assistant of a introductory programming course, and some students made this type of error:
which is not surprising as they are learning… What is surprising is that, besides gcc warning, the code works (at least this part). I have been trying to understand and I wrote the following code:
Compiling and executing:
Can anyone explain why they are not different? I suspect it is because I cannot get the address of an array (as I cannot have Edit: I know that an array by itself is the same as the address of the first element, but this is not related to this problem, I think. For example:
prints:
I don’t understand why the second line begins with |
————————————————-
Answer
In your example, the array
When you apply the unary
A pointer that points to an array of 50 ints has type When you just use the name
You can see that these both are pointing to the same address – although |
addressof,c#,gcc,pointers |
Facebook Comments