   When to use arrays?
  When you should I use arrays?Should I try and use it as little as possible, or can I use itwhenever I want to (provided that it is used in a sensible way).Another thing is how BIG can an array be? Can I make it as big as I want? For example: World[1000][1000].I am asking because I am making a Text-Hack-Type game and I want to load my world into an array. And my world is BIG!!! Basiclly what I am asking is this GOOD programming: World[1000][1000]???Thanks alot:-) 
  If that is a byte array, it takes over 1 meg on the stack (which is bad)!If you need such big array, use a pointer to the data and allocate the necessary memory yourself.Be sure to free the memory also after usage Nik02EDIT: not over 1 meg, but a little short of that  [edited by - Nik02 on August 4, 2003 4:11:06 PM];quote:Original post by Laverok   When you should I use arrays?Should I try and use it as little as possible, or can I use itwhenever I want to (provided that it is used in a sensible way).When your needs call for constant-time random access and iteration, but not for constant-time arbitrary insertion, an array or std::vector will suit your needs. As you become more adept at programming, you'll learn more about the various data structures and learn when to use each of them. For the time being, arrays are fine.quote:Another thing is how BIG can an array be? Can I make it as big as I want? For example: World[1000][1000].That's waaaay too big. Arrays allocated on the stack (without using new or malloc) are limited to 64 kilobytes in guaranteed size. Also, keep in mind that you don't have to have the whole map in memory at once; only the screen that the player can see.How appropriate. You fight like a cow.   [edited by - sneftel on August 4, 2003 4:11:33 PM];  So I should only make my array as big as what can be seen on the screen by the player? OK... I get that... Should I constantly read from the file where my world is stored into the array, every time the player moves, does something, etc.Does that not take long? (reading from the file constantly) ;  If my level structure took 1000*1000 bytes, i would load it all at the beginning of a level. It's not a huge amount after all, and hd access is anyway much slower in little pieces.Note that the solution depends whether or not you wantto load the level piece by piece, for some reason EDIT: typos   EDIT 2: I assume using PC architecture, although it hasn't explicitly been mentioned.Other platforms may not necessarily have so much of work memory to spare.[edited by - Nik02 on August 4, 2003 4:22:40 PM] [edited by - Nik02 on August 4, 2003 4:25:33 PM];  THANK YOU! THANK YOU!    THANK YOU!Now, back to my game.