C++ / Code:Blocks issue with memory

0

I getting error when compiling this code:

 int i[720][720];

error: Process returned -1073741571 (0xC00000FD).

It is ok if I declare:

int i[719][719];

what happens?

EDIT:

Ok... I did like you said. It works now. I tried to correct code for multiply big numbers from here.

I had to also change

        if(carry < 10){
            mat[i][j-(SIZE-1-i)]=carry;
            carry=0;
        }

to

        if(carry < 10){
            if (j-(SIZE-1-i) < 0) continue;
            mat[i][j-(SIZE-1-i)]=carry;
            carry=0;
        }
c++
arrays
memory
asked on Stack Overflow Jul 12, 2016 by Piotr Wasilewicz • edited May 23, 2017 by Community

3 Answers

0

Your stack is too small and you should be using dynamic allocation instead (e.g. std::vector or new). If you want to keep using stack allocation, you can increase stack size in compiler options or command line (depends on the compiler which you didn't state).

answered on Stack Overflow Jul 12, 2016 by SurvivalMachine • edited Jul 12, 2016 by SurvivalMachine
0

The error is that your array is too big to store it in the standard stack space of your compiler. You can try to compile your code on the online Codechef compiler. It has very big capacity of stack. The link is: https://www.codechef.com/ide

Or ofcourse, you could use a vector using std::vector or dynamically alloctae your array using the new keyword (not very highly recommended).

answered on Stack Overflow Jul 12, 2016 by Vaibhav Bajaj • edited Jul 12, 2016 by Vaibhav Bajaj
-2

Why do you want to create array of this size? To make it more memory efficient try using dynamic arrays declared using the keyword new. Example: myArray = new int [10] They can expand according to your need and its memory efficient as well.

answered on Stack Overflow Jul 12, 2016 by Saifay • edited Jul 12, 2016 by NathanOliver

User contributions licensed under CC BY-SA 3.0