In my code I have a large static 2D arrays defined as:
code:
Expand|Select|Wrap|Line Numbers
- #define LONMAX 1440
- #define LATMAX60 480
- void main (int argc, char *argv[])
- {
- .......
- float precip60[LATMAX60][LONMAX];
- float error60[LATMAX60][LONMAX];
- char source60[LATMAX60][LONMAX];
so in order not to pass the whole large array to another large array in the function I thought I just pass the address to a pointer.
code:
Expand|Select|Wrap|Line Numbers
- nread = read3B4XRT2B (LATMAX60, fp, precip);
- nread = read3B4XRT2B (LATMAX60, fp, error);
- nread = read3B4XRT1B (LATMAX60, fp, source);
- .......
- }
- int read3B4XRT2B (
- int latmax,
- FILE *fp,
- float *out)
- {
- int row, col;
- int nread;
- short int buffer[LONMAX];
- for (row=0; row<latmax; row++)
- {
- nread = fread (buffer, 2, LONMAX, fp);
- for (col=0; col<LONMAX; col++)
- {
- if (buffer[col] == I2MISSING)
- *(*(out+row)+col) = FMISSING;
- else
- *(*(out+row)+col) = buffer[col] / SCALE;
- }
- }
- return nread;
- }
is not compiled
compiler error message:
In function read2B4XRT2B Invalid type argument of `unary*'
I do not understand why this code is not working, I'm passing a 2D array as an address to another function as a pointer then storing data in the content pointed to by that pointer.
I hope someone can help me with that code.
Thanks in advance.
mshaaban