I was asked this in an interview. What will be the result of this program? I confidently said that this will not compile. I said that a is an array name and does not take up any space, so &a should not make any sense, hence this will not compile. but on hands-on, it turns out that compiles as well as runs successfully. Could someone please explain, how this works.
main()
{
int a[50];
&a; // or perhaps the interviewer wanted to know the output of this line..
}
The &a; line just computes the address of the array a, and silently discards it.
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