|
||
|
|
#1 (permalink) |
|
Forum Newbie
|
I'm currently writing a program, that needs a two-dimensional array on float values. How do initialize a 2-dimensional array without specifying it's exact size?
|
|
|
|
|
|
#4 (permalink) |
|
Forum Expert
|
Or, put another way that isn't the slower way of doing it:
Code:
Int32 size1 = 250
, size2 = 100;
Int32 [,] array = new Int32[size1, size2]
Also, I'm not so sure that's what the OP wants. I'm thinking it's something along the lines of: Code:
Int32 lowerSize = 100; Int32 [,] array = new Int32[,size]; There's something along the lines of what he's talking about in C++, but it doesn't really have to do with array initialization (still it's the first thing I thought of when reading his post): Code:
void f(int a[][10])
{}
int main()
{
int a[1][10];
f(a);
}
Of course, I could be wrong as well, just have to wait until they answer Courageous' question. |
|
|
|
|
|
#5 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
he is probably talking about pointers but as far as I can tell, you cant do it in any language. you cant initialize something if you dont know the size. you need to use dynamic arrays/data structures.
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." |
|
|
|
|
|
#6 (permalink) |
|
Forum Newbie
|
it can be easily done on PHP (so says my friend- who's a PHP freak
) |
|
|
|
|
|
#7 (permalink) | |
|
Forum Expert
Join Date: Sep 2002
Age: 23
Posts: 1,472
|
Quote:
|
|
|
|
|
|
|
#8 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
however you could use pointers in C++ for that matter (arrays are basically pointers): int** myArray
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|