1. ## 2d array definitions

This works:

Code:
`int vector[2][3] = {{5,5,5},{5,5,5}};`
This does not work:

Code:
```int vector[2][3];
vector = {{5,5,5},{5,5,5}};```
I've toyed around with it some, but I cannot figure out what I'm doing wrong.

2. Originally Posted by jsrig88
This works:

Code:
`int vector[2][3] = {{5,5,5},{5,5,5}};`
This does not work:

Code:
```int vector[2][3];
vector = {{5,5,5},{5,5,5}};```
I've toyed around with it some, but I cannot figure out what I'm doing wrong.
The way you are trying to initialize in the first one can only be done when you are declaring an array, which is why the first one works. In order to initialize after you declare it, you must do it by iterating through the array one by one.

3. When looking deeper, here:
Code:
`vector = {{5,5,5},{5,5,5}};`
vector is just an address of first element in an array of arrays. It makes no sense to try to change the poiner to {{5,5,5},{5,5,5}}.

4. You have got to be kidding me. I know that you can use an array's name as a pointer to that array, so I thought that I could use the pointer and define it thusly. It surprises me that it doesn't work that way.

5. Originally Posted by jsrig88
You have got to be kidding me. I know that you can use an array's name as a pointer to that array, so I thought that I could use the pointer and define it thusly. It surprises me that it doesn't work that way.
array is not a pointer, there are situations when array name is automatically casted to the pointer to the first element of the array...

but you cannot modify it

it just like saying that because 2+3 is int you think it is logical to assign to it some other value like
2+3 = 6