Allocating Huge Arrays in MSC 5.0
Pierre-Yves Thoulon
pyt at hprnd.HP.COM
Fri Jan 6 14:48:13 AEST 1989
I guess the problem is with your pointer arithmetic. I don't think the
compiler likes (vector + i) when i is such that the resulting pointer
would cross the 64K boundary. I'd rather use the following:
double huge *vector, huge *index;
int i, number_of_elements, retval;
...
vector = (double *) malloc( number_of_elements * sizeof( double ) );
index = vector; /* to save the base pointer value */
for( i = 0; i < number_of_elements; i++ )
{
retval = fscanf(infp,"%lf",index++ );
^^^^^^^
}
I've had the same kind of problem recently, I was using a vector[i]
notation for a huge vector. It worked fine until I went beyond the
first 64K limit. Incrementing a pointer as above solved the problem.
(took me a while to figure out... !)
Hope this helps.
Pyt.
More information about the Comp.lang.c
mailing list