0

This is my struct

struct Entry {
    int a;
    int b;
};

int main() {

    struct Entry data[260000]; //ok
    struct Entry data[262144]; //crash

    return 0;
}

I want to declare an array of Entry with the size is 2^18 (262144 elements) But I'm not able to do so. It seems like I go beyond the max. Is there another way to do this?

Louis Tran
  • 1,154
  • 1
  • 26
  • 46

1 Answers1

4

There is not ehough room in the auto context (on the stack) for that array, declare it static or as a global, or allocate it dynamically.

Jasen
  • 11,837
  • 2
  • 30
  • 48