| Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | About BLU |
Guys,
I've got a standard c coding question which has been nagging me for a
while and I was wondering what you guys may think or have the correct
solution to this problem....
Lets say I have a 2 dim array of data and the dimension sizes can change
depending on the specific data set. I can read in the x and y dimensions
from a file, then read in the x*y elements of the data a populate a
memory area x*y*elementsizeinbytes with the data. But now I want to
access the data. Without doing pointer arithmatic, is it possible to use
the standard [][] notation somehow?
for example
int *data;
x=getXDim();
y=getYDim();
data=(int *)malloc(x*y*sizeof(int));
readInData(x,y,data);
printf("Middle data element is %d\n",data[y][x]);
but I know that that data[y][x] will barf on the compiler because the
compiler has no way of knowing what the y size of the "y" dimension is...
Any suggestions on how to use the N-dimensional bracket notation in this
situation?
Thanks.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
Discuss mailing list
[hidden email]
http://lists.blu.org/mailman/listinfo/discuss