# Thread: Why is this wrong?

1. ## Why is this wrong?

I saw this on a tutorial, but it doesnt work:

Code:
``` char multi[5][10];
multi[0] = {'0','1','2','3','4','5','6','7','8','9','0'};```

2. Code:
`{'0','1','2','3','4','5','6','7','8','9','0'}`
Initializes an array, but you are actually defining it first and then assigning, which is a no-no.

3. You can do that only in defining line.

4. Its also initializing 11 array members, but the array is only 10.

5. I didnt understand well, can you type an example for me?

I want to make a 2D matrix (array of arrays), so i saw on a tutorial this way:

Code:
``` char multi[5][10];
multi[0] = {'0','1','2','3','4','5','6','7','8','9'};
multi[1] = {'0','1','2','3','4','5','6','7','8','9'};
multi[2] = {'0','1','2','3','4','5','6','7','8','9'};
multi[3] = {'0','1','2','3','4','5','6','7','8','9'};
multi[4] = {'0','1','2','3','4','5','6','7','8','9'};```
But i get this error:

syntax error before '{' token in line:
"multi[0] = {'0','1','2','3','4','5','6','7','8','9'};"

6. Code:
```char multi[] = {'0','1','2','3','4','5','6','7','8','9','0'};
char multi[][2] = { { '0', '1' }, { '2', '3' } };```
And so on.

7. Originally Posted by Elysia
Code:
```char multi[] = {'0','1','2','3','4','5','6','7','8','9','0'};
char multi[][2] = { { '0', '1' }, { '2', '3' } };```
And so on.
I'm sorry, but that doesnt work either...

Error:

conflicting types for 'multi'

8. Of course not. It was two examples, not one. It's how you do it. You copy how I did it with your own variables.

9. ok, tnks!

Popular pages Recent additions