It may be a memory error actually.
Even though it may be smaller than your memory size, arrays are contiguous in memory (meaning for your definition it needs 4000000 char sized blocks right next to each other).
I'm a beginner myself, but it seems plausible that this may be your problem.
If I'm not wrong, static arrays (such as the one above), and all static data, actually, are created on the stack. By creating one as large as that you caused a stack overflow and the OS complained.
If you need to allocate big arrays (I think the definition of big in this case is >=64K. Of course, it's system-dependent) allocate them dynamically.
char *charmap=newchar[2000][2000];
EDIT: Okay, a friend just explained it to me. Those aren't technically static arrays, since they go out of scope when the function returns, but they are created on the stack.
Thanks all. So it isn't possible this way. Then what do you do if you want to make a game with a large map consisting of tiles? Eatch tile is occupied by something, a value. How is this done?
Thanks again, I hope you can help me further.
Well it's like we were saying, the problem isnt that your array is too big, it's just possible that your system's stack isn't big enough to handle it. What system are you using? Also, what compiler do you use?
Dynamic allocation will allocate memory in the heap right ? So how is that going to help ? Is the heap bigger than the stack ? I am sorry but i am new to memory management of c++ programs.
Not just "bigger". Much bigger. In fact, most of the memory installed in a modern computer (including virtual memory, which alone is already huge) counts as part of the heap.