开发者

Can an array be called as a const pointer?

开发者 https://www.devze.com 2022-12-21 03:34 出处:网络
this is very basic...but please help me if anybody know about this... Can开发者_开发百科 an array be called as a const pointer?Do you mean \"can array be used where a const pointer is expected\"? In t

this is very basic...but please help me if anybody know about this... Can开发者_开发百科 an array be called as a const pointer?


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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消