Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gmkwo

huge arrays

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

void main() { float arr[250][250][250]; } Why I get some unhandled exceptions? I use WinXP Home,MSVC++.NET Std and 512 MB RAM.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
because you''re allocating it all on the stack (local function variables are allocated on the stack) which by default is 1MB in windows programs.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by flangazor
int main()
{
float* arr = new float[250][250][250];
delete [] arr; // hm, delete [][][] arr; ?
return 0;
}

Syntax error. That''s far from the right way to do it!

Share this post


Link to post
Share on other sites
I would go with a vector of vectors of vectors. Something a little like:


std::vector<std::vector<std::vector<int> > > array(250, std::vector<std::vector<int> >(250, std::vector<int>(250)));


Or if you dont like ugly code, maybe use boost::multi_array

http://www.boost.org/libs/multi_array/doc/user.html

Plus it should be int main() not void main().

Hope that helps

Share this post


Link to post
Share on other sites
Umm is this thread C or C++ if its C than ok VOID MAIN() is ok but in C++ Mmain must return an int (which is why gcc gives u an error for void main())



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!