C++ - Is an array a pointer? [duplicate]
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
精彩评论