Segmentation Error creating an array in C

Recently, I switched to a new laptop - HP dv6119tx (Intel Core i5, 4 GB RAM). It has the 64-bit version of Windows 7 Home Premium installed.

I'm trying to create an array of type int10 ^ 6 long in C ++ (Dev C ++), which I used to comfortably create on my last laptop (32-bit Windows 7 Ultimate / Ubuntu Linux, 2 GB of RAM) and every other environment which I programmed for (it should occupy about 3.5 MB of RAM). But with the current setting, I get the error "Segmentation Error" in debug mode.

Screenshot when I am trying to create an array of length 10 ^ 5

Screenshot when I am trying to create an array of length 10 ^ 6

(EDIT):
10 ^ 5, 10 ^ 6 . 10 ^ 6, , .

EDIT:
,

int* a = new int[MAX];  

, , - , 3,5 ( 2 ), 4 ? ? ?

2:
, SPOJ 10 ^ 6, . , . , , ; , .

+5
3

. Windows - 1 . /STACK , .

+9

. , , stackoverflow .

- :

int *a = (int*)malloc(MAX * sizeof(int));

//  Do what you need to do.

//  Free it when you're done using "a".
free(a);
+8

Instead of malloc'ating memory, you can specify your buffer as static. For instance:.

static int a[MAX];

The advantage of this approach is that you do not need to track memory allocation.

+2
source

All Articles