   dumbest post ever
  why wont c++ let me declare an array like this?char map[2000][2000] it gives me windows runtime errors.char map[1000][1000] works finei have 1GB ram on my system i cant possibly be running out of memory.  any suggestions?  i need a structure to store my world map in where each element represents an index number to a tile from 0 to 255.  thanks for any advice.also having a helluva time trying to get random numbers.  i use srand and seed it with the time but every time i call a rand()%1 i get 0 and every time i all rand()%10 i get 1... arghhh[edited by - machiavelli on February 11, 2004 7:11:00 PM][edited by - machiavelli on February 11, 2004 7:13:11 PM]
  You are probably declaring that thing on the stack, and it is overloading the stack.If you create it dynamically, like this:char *map = new char[2000*2000];then it will work great   [edited by - pinacolada on February 11, 2004 7:18:20 PM];  rand()%1 will always return a 0. The % operator returns the remainder when the left side is divided by the right side, so any number divided by 1 will have a remainder of zero. I'm not sure about your rand()%10 problem, though.No, I believe the award for "dumbest post evar" belongs to:quote:yo d00dz, ware kin i buy c++??!1` [edited by - psykr on February 11, 2004 7:33:37 PM];  If you insist on putting it on your stack, you'll need to commit more stack space.  If you're using Visual C++ 6.0 or .NET, go to your project build properties and change your Stack Reserve to something like 16000000.If you're not using a microsoft SDK just put it on the heap like pinacolada suggested by dynamically allocating it.   [edited by - J1NX on February 11, 2004 7:41:23 PM];  thx guyz you rule. ;  yes, you are obviously trying to create a tile-based map. The best piece of advice is to use a dynamic structure like so:int COLS = 100; // user can change theseint ROWS = 100;struct maptile {int x;   int y;   int whatever;} **the_map; // the map pointer-pointer array// build the dynamic mapthe_map = new maptile *[COLS]; // pointer arrayfor (int counter = 0; counter < COLS; counter++) {the_map[counter] = new maptile [ROWS];}   Someone recommended that too me when i first started a similar project. It's nice this way because you can define that map dynamically and even let the player resize it using similar techniques   [edited by - leiavoia on February 12, 2004 1:10:19 AM]