Initializing array with two pointers

arrays, c

Solution

`int **` is a pointer type not an array type. Pointers are not arrays. Use type `int [3][4]`.

You cannot pass arrays to functions but you can pass a pointer to an array. A function declaration to pass a pointer to an array 4 of `int` would be:

void f(int arr[3][4]);

or

void f(int arr[][4]);

or

void f(int (*arr)[4]);

The three declarations are equivalent.

Problem

``` int main() { int **matrix = { {1, 3, 2, 4}, {3, 2, 4, 5}, {9, 3, 2, 1} }; getchar(); } ``` - Why does this display warnings like "braces around scalar initializer"? - Why do I need to initialize multidimentional arrays with more than one pointers? (if you could give me some pretty easy-to-understand explanation on this one...) - If I'd want to use int matrix[3][4] instead of int **matrix...what would be a function parameter if I'd want to pass this array? `int[][]`?

Original source