1. ## array of rectangles

I want to create an array of rectangles. How would I got about doing this? Do I create an array of RECT? are there other ways?

2. Use RECT with win32, CRect or RECT with mfc; other class libraries may have similar structures/classes defined for use. How you set up your array is entirely up to you. Here's 3 possible ways:

RECT rc[100];

const int NUM_RECTS=100;
RECT *rc=new RECT[NUM_RECTS]; /*...and later*/ delete[] rc;

#define NUM_RECTS 100;
RECT *rc=(RECT*)malloc(sizeof(RECT)*NUM_RECTS); /*...and later*/ free(rc);

3. There is no other way.

4. >>There is no other way.<<

Future proofing.

5. Well its the same as any other data type. Do you know how many you need before hand or at run-time?

If you know how many you need then you can do it like this:
Code:
```// An array of 5 rects
RECT myRects[5];
int i;

// Set a certain rect to something
for( i = 0; i < 5; ++i )
{
SetRect( &myRects[i], 10, 20, 30, 40 );
}```
Or if you find out a run-time..
Code:
```// Assume nRects is initialized to number of RECT's we need
RECT *pRects = NULL;
int i;

pRects = new RECT[ nRects ];
if( pRects == NULL )
{
FatalAppExit( 0, "Out of memory" );
}

// Setup the rects
for( i = 0; i < nRects; ++i )
{
SetRect( (pRects + i), 10, 20, 30, 40 );
}

// Free memory
delete [] pRects;```

6. Thanks!

Well, i want to build a cellular automata program (Conways game of life) so I'll have a set amount of rectangles before hand.

Thanks again!