"Ohmu" <ohmar@hot.ee> wrote in message
news:37c0fd9c.0308300447.1963ea4d@posting.google.c om...[color=blue]
> "John Harrison" <john_andronicus@hotmail.com> wrote in message[/color]
news:<biplo1$bqaq9$1@ID-196037.news.uni-berlin.de>...[color=blue][color=green]
> > 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);
> >[/color]
> <snip>[color=green]
> > // one dimension with reference
> > void function(int (&a)[10]);
> > int array[10];
> > function(array);[/color]
> <snip>[color=green]
> >
> > john[/color]
>
> but how to pass the array when the size is read from file, int[/color]
array[size][size] ??[color=blue]
>
> Ohmu[/color]
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