which seems to work like a charm, since it is followed by
read(fp, &data[0][0], num_of_bytes); /* this works ... */
this (i think) just places a chunk of data (size num_of_bytes) into the contig-
uous dynamic array data[i][j].
*now*, this array data[i][j] is passed to a function as follows:
main(){
[...]
Function(data, xstart, ystart, xend, yend); /* called within main() */
/* declared in separate */
/* module */
[...]
}
then inside a _separate_ module:
Function(data, x_start, y_start, x_end, y_end) /* start separate module */
unsigned short **data;
short x_start, y_start, x_end, y_end; /* these let you process any */
{ /* subset of the array if need be */
[...]
mean = 0;
for(i = x_start; i < x_end; i++){
for(j = y_start; i < y_end; j++)
mean = mean + *(data[i] + j);
}
[...]
}
then this is compiled (on an HP Apollo 400 series) as follows:
% cc -c function.c
% cc -o main main.c function.o -lm
all the code above works on *square* arrays (tested up to 512 x 512).
however, it crashes on *rectangular arrays* (for instance 128 x 21) with the
following error message:
% segmentation fault (core dumped) /* for the millionth time ... */
i have placed a printf() inside the averaging loop above, telling me when
each element of *(data[i] + j) is accessed. the programs chugs along until it
gets up to data[50][0]. then the error occurs.
i seem to recall having this same problem in main() (with the read statement)until i made sure the allocated array was contiguous; but i could be mistaken.
any ideas? hopefully this has been coherent -- but if not, i'd be happy to
correspond via email if anyone is interested. any feedback would be *greatly*