SW> I have an array of one of my structures that is too big
SW> for my compiler... I have tried all the memory models for
SW> Turbo C++ 3.0, but it still won't work.
heh... No real surprise there. Try using dynamic allocation.
You may experience difficulty if you attempt to run this in
the IDE, however. At least I did in BC++3.1. But then, my
system probably is not the most stable, even under the best
of all possible conditions. :)
You might also consider making maptile a class and putting
all the code to handle the data in the class itself.
That way, you are making maptile a data object, and your
program simply manipulates the object.
#include
#include
/* If someone would be kind enough to post a quick tutorial
on using ostream with strings, I could get rid of sprintf()
and not fall back on . :)
*/
typedef struct {
char maptype, special[81], text[341];
unsigned x, y;
int attr, ansifg, ansibg, ansiattr;
} maptile;
int main(void)
{
int level, map;
maptile ***local_map;
local_map = new maptile**[9];
/* create and allocate memory for a pointer to array
of pointers to array of pointers to maptiles */
for(level = 0; level < 9; level++)
{
local_map[level] = new maptile*[21];
/* allocate memory for 9 maptile pointer arrays */
for(map = 0; map < 21; map++)
{
local_map[level][map] = new maptile;
/* allocate memory for 21 maptile structs */
sprintf(local_map[level][map]->text,
"L%d|M%d ",
level, map);
}
}
for(level = 0; level < 9; level++)
{
for(map = 0; map < 21; map++)
{
cout text;
delete local_map[level][map];
/* de-allocate the maptile structs */
}
cout << endl;
delete []local_map[level];
/* de-allocate the maptile pointers */
}
delete []local_map;
/* de-allocate maptile pointer pointers */
return 0;
}
> ] I'm not materialistic. I'm just Object Oriented.............
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|