Jump to content
  • Advertisement
Sign in to follow this  
willthiswork89

quick question

This topic is 4863 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

Advertisement
what exactly do you mean by 'cells'? If you are asking how big an array can be, i.e. how much memory can a single array hold then the answer is theoretically infinite. There is no law (that i'm aware of) stopping you from creating one array from all available system memory. I have seen an array of 1000000 chars before (of course this was only for testing reasons and served no true purpose). hope that helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by willthiswork89
me and my buddy were talking and i was wondering...is there a maximum number of "cells" an array can hold? i heard it was 256?
No, that's certainly not true. The actual max array size will probably depend on whether you create it on the heap or the stack, as well as other possibly platform- or compiler-specific factors, but it will generally be orders of magnitude greater than 256.

Share this post


Link to post
Share on other sites
If you are using C++ use std::vector rather than arrays (unless you have a good reason to use an array). In which case here's some code that'll answer your question
#include <vector>
#include <iostream>
using namespace std;

int main()
{
vector<int> foo;

// output the maximum number of elements foo can hold
cout << foo.max_size() << endl;
}


If you're stuck with C, i'm not sure what the answer to your question is, but i'm sure that it is much higher than 256.

Share this post


Link to post
Share on other sites
Let's put it this way. They can be big enough for anything you could possibly do [grin] Don't worry about hitting some theoretical boundary at which arrays stop, there is no such thing, as long as you have the physical memory, you can use it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!