L
lloyd
Hi,
I would like to set up a 2-D array of floats representing a function
of integer coordinates from the half-plane above (and including) the x-
axis. To be specific, I will calculate a function for each of the
integer points inside (and on the boundary of) the rectangle formed by
(-100,0) to (100,0) to (100,100) to (100,-100). This is a 101x201
rectangle which I would declare as follows:
double A[201][101];
I think it's possible to define a pointer p referring to the middle of
this array, so that I can use intuitive coordinates like p[-43][21]
inside my program to write to and access the array relative to the
pointer. Could someone tell me how to figure out what to define p as?
If I only had a one-dimensional array I think I could put
int p=A+100;
(or would I need to multiply 100 by the size of a float because it's
an array of floats, not ints?)
Thanks. I always use arrays instead of pointers and so there are some
gaps in my knowledge...
I would like to set up a 2-D array of floats representing a function
of integer coordinates from the half-plane above (and including) the x-
axis. To be specific, I will calculate a function for each of the
integer points inside (and on the boundary of) the rectangle formed by
(-100,0) to (100,0) to (100,100) to (100,-100). This is a 101x201
rectangle which I would declare as follows:
double A[201][101];
I think it's possible to define a pointer p referring to the middle of
this array, so that I can use intuitive coordinates like p[-43][21]
inside my program to write to and access the array relative to the
pointer. Could someone tell me how to figure out what to define p as?
If I only had a one-dimensional array I think I could put
int p=A+100;
(or would I need to multiply 100 by the size of a float because it's
an array of floats, not ints?)
Thanks. I always use arrays instead of pointers and so there are some
gaps in my knowledge...