M
my.correo.basura
Hi,
I'm having some problems working with two-dimensional arrays. Here's
the story.
I got two 50x50 matrixes (is that the plural of matrix?) defined at
compile time.
I want to work with them inside a for loop, but depending on the
iteration, one is the real one and the other is dummy. At the end of
the iteration I swap them.
I'm working with pointers but it is'nt working as assignments in lines
15 and 16 are from different types. I'm pretty sure I've been through
this before but can't remember how I solved it. Any help? Here's the
code I've got:
-----------------
#include <stdio.h>
#define ROWS 50
#define COLS 50
#define MAXITERS 100
int main(void){
int matrix1[ROWS][COLS];
int matrix2[ROWS][COLS];
int **realMatrix;
int **dummyMatrix;
int **swapMatrix;
int i;
realMatrix=matrix1; /*Line 15*/
dummyMatrix=matrix2; /*Line 16*/
for (i=0; i < MAXITERS; i++){
/*Work with Matrix*/
/*...*/
/*Swap Matrix*/
swapMatrix=realMatrix;
realMatrix=dummyMatrix;
dummyMatrix=swapMatrix;
}
return 0;
}
I'm having some problems working with two-dimensional arrays. Here's
the story.
I got two 50x50 matrixes (is that the plural of matrix?) defined at
compile time.
I want to work with them inside a for loop, but depending on the
iteration, one is the real one and the other is dummy. At the end of
the iteration I swap them.
I'm working with pointers but it is'nt working as assignments in lines
15 and 16 are from different types. I'm pretty sure I've been through
this before but can't remember how I solved it. Any help? Here's the
code I've got:
-----------------
#include <stdio.h>
#define ROWS 50
#define COLS 50
#define MAXITERS 100
int main(void){
int matrix1[ROWS][COLS];
int matrix2[ROWS][COLS];
int **realMatrix;
int **dummyMatrix;
int **swapMatrix;
int i;
realMatrix=matrix1; /*Line 15*/
dummyMatrix=matrix2; /*Line 16*/
for (i=0; i < MAXITERS; i++){
/*Work with Matrix*/
/*...*/
/*Swap Matrix*/
swapMatrix=realMatrix;
realMatrix=dummyMatrix;
dummyMatrix=swapMatrix;
}
return 0;
}