"Ohmu" <> wrote in message
news: om...
> "John Harrison" <> wrote in message
news:<biplo1$bqaq9$>...
> > Here's how to prototype and call functions with arrays, references and
> > pointers.
> >
> > // one dimension with pointer
> > void function(int *a);
> > int array[10];
> > function(array);
> >
> <snip>
> > // one dimension with reference
> > void function(int (&a)[10]);
> > int array[10];
> > function(array);
> <snip>
> >
> > john
>
> but how to pass the array when the size is read from file, int
array[size][size] ??
>
> Ohmu
int array[size][size]; is not a legal array declaration.
If your 2d array is dynamic then you need to allocate some memory for it and
use pointers. E.g.
void function(int** a);
int **array;
array = new int*[size];
for (int i = 0; i < size; ++i)
array[i] = new int[size];
function(array);
This question is in the FAQ
http://www.parashift.com/c++-faq-lit...html#faq-16.15
john