Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, i have a question!
I want to create multiple arrays depending on users input!
lets say i wanna create 5 arrays
x=0
while(x5)
{
char[] |__| = new char[10];
}my question is how do i make up names? for it.. if i put i in there it doesnt recognize it!
Thanks in advance!

Well it is screwed up a little
let me write againwhile(x islessthan 5)
{char[] ? = new char[];
}
I ment if i put 'x' there it doesnt work, gives me error..
thanks

I'm not exaclty sure what your trying to do, but I think your getting the error because your trying to name the array with an integer...
thru each iteration your going to get:
char[] 0 = new char[];
char[] 1 = new char[];
char[] 2 = new char[];
and so on...and I think you may need to declare the length or else set to null..
char[] x=null;
-or-
char[] x=new char[10];

Try this:
First, you should declare an empty array. After that, user has to declare how many elements this array should have (let's say 5 elements, you can enter that value from keyboard). Then, you will have to create a new array with desired number of elements and, finally, make old array equal to the new array.
I believe that following code should work:int numberOfElements;
char[][] initialField = null;
numberOfElements = 5;
if( numberOfElements > 0 )
{
char[][] newFieldSizedByUser = new char[numberOfElements][10];
initialField = newFieldSizedByUser;
}Is far as I know, you have to use both arrays (you can't do that with only one array).

![]() |
Block TCP ports with VB
|
Recommended Site or Book ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |