pointers & array

Hey guys , is there a difference between number 1 and number 2 ?
1
2
3
4
5
6
7
8
9
  int array[10];
int *ptr=array; 

// the above is number 1

// here is number 2

int array[10];
int (*ptr)[10]=&array
number 1
it is initialization of pointer with adress of array array
ptr points to int array of length 10

number 2
it is initialization of two-dimensional int array with one-dimensional
you have an array of 10 pointers (because length of array is 10) and each of them points to int array with length of 10
Last edited on
The first ptr is a pointer to a single integer, which is initialized to point to the first element of array, that is, to array[0]

The second ptr is a pointer to the entire array of 10 int, which is initialized to point to the array array

Topic archived. No new replies allowed.