1

Possible Duplicate:
C: differences between pointer and array

Is an array in C++ a pointer? Can you clarify this?

Thanks.

Community
  • 1
  • 1
Simplicity
  • 44,640
  • 91
  • 243
  • 375
  • 1
    This question is not **exact** duplicate as it asks for C++ and there is more to it in C++ than in C. – Jan Hudec Mar 04 '11 at 10:34

2 Answers2

8

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
}
Erik
  • 84,860
  • 12
  • 192
  • 185
3

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
Shamim Hafiz - MSFT
  • 20,466
  • 38
  • 110
  • 169