hi guys, it's been a while since i used c for anything so here goes a question tha may seem silly.
I have 2 variable length arrays....
int main()
{
int n = 5;
int m = 6;
int before[n][m];
int after[n][m];
array_function( 5, 6, before, after );
}
void array_function(int rows, int cols, float after[rows][cols] , float before[rows][cols])
{
//for some iterations
for(;;)
{
//for all the elements int the array
for (i=1; i<rows; i++)
for(j=1; j<cols; j++)
after[i][j] = 4 * before[i][j]
//afterwards prepare for the next iteration [1]
for (i=1; i<rows; i++)
for(j=1; j<cols; j++)
before[i][j]=after[i][j];
}
}
...What i want to do is find a way to swap the pointers to the arrays. So that i can get rid of the last loop.
I figured that since i only need to calculate "after" based on "before" and then make "after"->"before" and recalculate "after".
It would save a lot of time if i just swapped the 2 pointers.
i tried the following but with no luck:
//define function like this:
void array_function(int rows, int cols, float &after[rows][cols] , float &before[rows][cols])
//call it like this:
array_function( 5, 6, &before, &after );
thanks in advance
-nicolas