Mail Archives: djgpp/1997/03/02/00:39:49
> From: Iain Buchanan <Iain AT BuchananFamily DOT demon DOT co DOT uk>
>
> struct defPt
> {
> float x, y, z;
> int sx, sy;
> };
>
> And an array full of pointers to such structres:
> defPt *View[25][25];
>
That's how I'd do it:
#define max_x 25
#define max_y 25
defPt *View;
main ()
{
View = (defPt *) malloc (sizeof (defPt) * max_x * max_y);
// referencing
*(View + x + y * max_x) = 25;
some_int = (View + x + y * max_x)->sx;
}
You'll get warnings saying that you are converting int to pointer whithout
a cast. Just ignore them. It works. (Unless someone else knows something
else about it that I don't).
Cristovao Braga.
- Raw text -