Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit to array size?

Status
Not open for further replies.

JimmyFo

Programmer
Feb 14, 2005
102
0
0
US
Hi, I am trying to create an array of structs to hold some basic information. I'm looking at something like this:

struct frame
{
int file1[153];
string file2[153];
int file3[153];
float file4[153];
};

frame newArray[558];

I can build this in VS 2005, but when I try to run it, I get a memory access error. I started with an entirely blank project, and have only on .h and one .cpp file, less than 100 lines at this point.

If I take the newArray[] size down to around 250, it's ok - why is this?

Thanks,
James
 
Your array it too big for your stack. Allocate it on the heap instead:
Code:
frame* newArray = new frame[ 558 ];
 
Or even better, just use a vector instead of an array:
Code:
vector<frame> newArray;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top