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
  • 47,404
  • 98
  • 256
  • 385
  • 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
  • 88,732
  • 13
  • 198
  • 189
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
  • 21,454
  • 43
  • 116
  • 176