1. ## Random Variable names

I have a standard variable name VarX, where X is a random number wich is in Integer Num.

How can i create a varable with the name VarNum, for example if Num = 3, VarNum would be like Var3.

How can i achieve that?

Thanks!

2. You can't. However there are such things as arrays.

3. Originally Posted by anon
Quote:
Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

Quoted more than 1000 times (I hope).
Phirst!

It's not VarX that you want, but Var[X]. Learn arrays.

4. I know arrays, i was avoiding to make and array inside other array inside other array, because i already had a 2D array...

5. That's the way it works...

6. This reminded me of my first job maintaining a DOS based application. The original programmer used multiple global variables named : flag1, flag2...flag137... There were literally hundreds of them. None of his functions took parameters. All variables were GLOBAL! His function names were like random letters jumbled together. They had no relation to the function, ie. it wasn't an acronym. Amazingly the program ran and was used in a professional company that was actually fairly successful.

7. Ok, why is this 3 of 3 arrays wrong:

Code:
```     matrix[3][3][3];
matrix[0] = {{{{'1','2','3'},{'1','2','3'},{'1','2','3'}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}},{{'1','2','3'},{'1','2','3'},{'1','2','3'}}};```
I'm doomed..

8. An array is not a modifiable lvalue, so it cannot be assigned. It can be initialized:
Code:
```   char matrix[3][3][3] =
{
{{'1','2','3'},{'1','2','3'},{'1','2','3'}},
{{'1','2','3'},{'1','2','3'},{'1','2','3'}},
{{'1','2','3'},{'1','2','3'},{'1','2','3'}},
};```

9. Split the initialization across several lines. Having everything on one line is absolutely ridiculous and confusing. If I had to guess just from looking at your massive line of code, I would suspect that you are missing curly braces throughout.

10. Code:
```char matrix[3][3][3] =
{
{
{ '1', '2', '3' },
{ '1', '2', '3' },
{ '1', '2', '3' }
},
{
{ '1', '2', '3' },
{ '1', '2', '3' },
{ '1', '2', '3' }
},
{
{ '1', '2', '3' },
{ '1', '2', '3' },
{ '1', '2', '3' }
}
};```
Couldn't resist.

11. Couldn't resist.
Code:
```char matrix[3][3][3] =
{
{
{
'1',
'2',
'3'
},
{
'1',
'2',
'3'
},
{
'1',
'2',
'3'
},
},
{
{
'1',
'2',
'3'
},
{
'1',
'2',
'3'
},
{
'1',
'2',
'3'
},
},
{
{
'1',
'2',
'3'
},
{
'1',
'2',
'3'
},
{
'1',
'2',
'3'
},
},
};```
Seriously, there is a fine line between readable and spaced-out whitespace. Use whatever whitespace you think makes it easier to read. But there's no need to go too far.

12. I think that is a little too far.

13. Dave wins spacing battle.

14. Dave is making it difficult to separate the different dimensions. That's why I went a step further.

15. I thought Elysia was splitting hairs. That's why I went a step further. (Of course, that's probably how I would indent it, anyway . . . .)

I think that is a little too far.
That was the point.