Take the 2-minute tour ×

this is very basic...but please help me if anybody know about this... Can an array be called as a const pointer?

share|improve this question
Please rephrase: currently, your question cannot be understood ("call an an"). Provide an example of what you are trying to do. –  Pontus Gagge Feb 26 '10 at 12:18
Is this a HW question? What do you mean by const pointer? It could be at least (e.g.) const char *foo and char *const foo –  Matthew Flaschen Feb 26 '10 at 12:20
add comment

3 Answers

up vote 5 down vote accepted

Do you mean "can array be used where a const pointer is expected"? In that case, yes:

void f(const int* p)

int ar[10];
f(ar); // this works, array is essentially a pointer
share|improve this answer
add comment

if you are referring to the array's address then YES it will be a constant.

share|improve this answer
add comment

Yes. An array always decays to a pointer when passed as a parameter to a function.

share|improve this answer
add comment

Your Answer


