开发者

C++ - Is an array a pointer? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

C: differences between pointer and array

Is an array in C+开发者_如何学Python+ a pointer? Can you clarify this?

Thanks.


No. But it can decay to a pointer whenever you need it.

void foo1(char * c) {
}


int main() {
  char Foo[32];
  foo1(Foo); // Foo decays to a pointer
  char * s = Foo; // Foo decays to a pointer which is assigned to s
}


The array name itself without any index is a pointer.

int a[10];
printf("%d\n",*a); // will print first value
printf("%d\n",*(a+1) ); // will print second value
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜