Question: I wrote a simple program to test array pointer:

```
    #include <iostream>

    using namespace std;

    int main(){
        int (*array)[10];
        int i, j;
        for (i = 0; i < 10; i++){
            for (j = 0; j < 10; j++)
                array[i][j] = 1;
        }
        for (i = 0; i < 10; i++){
            for (j = 0; j < 10; j++)
                cout << array[i][j] << " ";
            cout << endl;
        }
        return 0;
    }

```

why the g++ "Segmentation fault"?
by the way, my os is ios x64.

Thanks
Chuan

Answer: 
`array` is a pointer to an array, which you apparently already know. However, you never allocated memory for the actual array, i.e. your pointer is pointing "nowhere". You are trying to access something that does not exist, which often leads to segmentation fault.

For example, you can declare an actual array

```
int array10x10[10][10];

```

and make your pointer point to it

```
array = array10x10;

```

(more precisely, your pointer is now pointing to the first 10-element subarray in `array10x10`). After that your code will work fine, meaning that by accessing `array[i][j]` you will indirectly access `array10x10[i][j]`.

Alternatively you can allocate the actual array in dynamic memory, if you so desire

```
array = new int[10][10];

```

(just don't forget to do a `delete[] array` at the end).
You declare `array` as an array of pointers, then use it as an array of arrays.

You must declare it as multi-dimensional instead :

```
int array[10][10];

```