C Programming - Arrays - Discussion

Discussion Forum : Arrays - Yes / No Questions (Q.No. 2)
2.
Does this mentioning array name gives the base address in all the contexts?
Yes
No
Answer: Option
Explanation:

No, Mentioning the array name in C or C++ gives the base address in all contexts except one.

Syntactically, the compiler treats the array name as a pointer to the first element. You can reference elements using array syntax, a[n], or using pointer syntax, *(a+n), and you can even mix the usages within an expression.

When you pass an array name as a function argument, you are passing the "value of the pointer", which means that you are implicitly passing the array by reference, even though all parameters in functions are "call by value".

Discussion:
9 comments Page 1 of 1.

Mohan said:   6 years ago
Array name doesn't give base address when it is used with sizeof and &(address of) operator.
(2)

Rajeshwari said:   6 years ago
I think the answer has to be yes because an array name always gives the base address. If I am wrong, please clarify me.

Ragibi said:   8 years ago
Can you elaborate it @Mrmino.

Neela said:   8 years ago
I am bit confused about the answer, as I know array name always gives a base address. If not please explain me briefly.

Thanks in advance!

MrMino said:   10 years ago
A quick look at the call stack says that giving things "by reference" to functions in C passes pointer to base address anyway. At the call stack level every reference is still just a pointer.

Abdul Quadir said:   1 decade ago
I agree with @Prabhat.

An array name always gives the base address in all contexts.

Nikhil said:   1 decade ago
@Priya.

Base address is the address of the first element of the array.

Suppose we have an array arr[5]={2,4,8,9,12}.

Then base address is the memory location where the first element of the array arr i.e. arr[0] is stored.

Priya said:   1 decade ago
What is meant by base address please any one can be explain it?

Prabhat said:   1 decade ago
I don't agree with this statement. In 'call by refrence' also, array name gives base address of original array.

Post your comments here:

Your comments will be displayed after verification.