1. ## Question on arrays

For school I have to program a Blackjack game.

I'm using CodeBlocks.

Now it gives an error on a certain part of my code:

Code:
```int harten[13][2];
int ruiten[13][2];
int schoppen[13][2];
int klaveren[13][2];

InitialiseCards(){
harten[13][2] = {{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1},{11,1},{12,1},{13,1}};

ruiten[13][2] = {{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1},{11,1},{12,1},{13,1}};

schoppen[13][2]= {{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1},{11,1},{12,1},{13,1}};

klaveren[13][2]= {{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1},{11,1},{12,1},{13,1}};
}```
(harten, ruiten, schoppen and klaveren are the dutch names of the type of cards)

it could be a very stupid fault because I'm just a newbie, but I realy can't figure it out

I hope someone can help me

2. Can you give the specific error?

Also, can you explain why you are using 2d arrays?

3. the error:

Code:
`error: syntax error before '{' token`
the error points to this rule:

Code:
`harten[13][2] = {{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1},{11,1},{12,1},{13,1}};`
I'm using 2D arrays, because I want to make shure that a card isn't used 2 times

sow in the first part I keep the value of the card (1 - 13) and in the second part if the card has been taken allready (1 or 0)

4. You cannot assign an array like this. Exception: When the array is defined.

Code:
`int i[5] = {1, 2, 3, 4, 5}; /* ok */`
Code:
```int i[5]; /* definition is here */
...
i =  {1, 2, 3, 4, 5}; /* fails, too late to initialize */```
So move the initialization to the point where the arrays are defined or use a loop to fill the array:

Code:
```for (i = 0; i < 14; ++i) {
harten[i][0] = i + 1;
harten[i][1] = 1;
}```

5. I believe that initializing the array as you are trying to do can only be done at the declaration of the variable.

So inside of your initialization function, you coudl use a loop to assign the values to the array.

edit:
(i.e. see post above mine )

6. ok, thank you very much guys!

7. Also, as you should know, using the [] references a single element in the array, not the entire array. So how could you possibly assign several values to a single element?