-
An [n][n][m] array...
Sorry for post a lot :)
My problem is like this: I have to define an n+n matrix. Obviusly that is not a problem. The question is that in each element of the matrix, I have to define, say, k elements more.
It would be like this:
Code:
for(i=0;i<10;i++){
for(j=0;j<10;j++){
for(k=0;k<NSTEPS-1; k++){
cx[i][j][k]=i*k; //This is not obviusly what I'm tring to do
cy[i][j][k]=j*k;
printf("%f %f \n",cx[i][j][k],cy[i][j][k]);
}
}
}
But my compiler say I defined in a wrong way cx and cy. I tried to define them as
Code:
double cx[11][11][NSTEPS],cy[11][11][NSTEPS];
¿Do anybody know how can i defined that arrays? Thanks!
-
Works for me. May-be there's an error on the previous line? (Posting the actual error message and actual code that produces it might be helpful.)
However, note that you are skipping the last element of each dimension in your loops.
-
Maybe one of these reasons:
cx, cy are not declared at the start of a block.
NSTEPS isn't a #define constant.
-
This is stupid. I put the last element I was forgotten, and I defined in a correct way i and j.
The thing is that initially I tried to defined the matrix with decimal numbers, like
for(i=0;i<4.0;i=i+0.04), but then a corrected it, and I forget to defined i and j like integers. I'm very embarrased with you. Sorry for that stupid mistake. I promise check my codes after asking.
:(